# # Socket

Source: Internet
Author: User

# Server side

* The serversocket class monitors the specified port

* Serversocket Class Construction Method

Serversocket ();

Serversocket (INT port );

Serversocket (INT port, int backlog );

Serversocket (INT port, int backlog, inetaddress bindaddr );

* Waiting for client requests

Serversocket. Accept ();

# Client

* Socket class is the basis for implementing client sockets

* Constructor

Socket (inetaddress address, int port );

Socket (string host, int port );

Socket (inetaddress address, int port, inetaddress localaddr, int localport );

Socket (string host, int port, inetaddress localaddr, int localport );

The last two remote ports used to create and connect them to the specified remote address

* Send and receive data

Socket provides two methods to obtain the input and output streams of the socket respectively.

1. Accept the data getinputstream ();

2. getoutputstream ();

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.