Working with Java I/o 2

Source: Internet
Author: User

Java Socket Working mechanism

Sockets are an abstraction that describes the completion of communication between computers. There are many kinds of sockets, in most cases we use TCP/IP-based streaming sockets, which is a stable communication protocol.

Host A's application communicates with Host B's application and must establish a connection through the socket, and the socket connection must be established by the underlying TCP/IP to establish the TCP connection. Establishing a TCP connection requires the underlying IP to address the hosts in the network. The IP used by the network layer can help us to locate the target host based on the IP address, which is then specified by the TCP or UDP address, which is the port number. This makes it possible to use a single socket instance to uniquely represent the communication link for an application on a host.

Establish a communication link

When the client wants to communicate with the server, the client first creates a socket instance, the operating system assigns the socket instance a local port number that is not used, and creates a socket data structure that contains the local address, the remote address, and the port number. This data structure will remain in the system until the link is closed. Before the constructor for the socket instance is returned correctly, the 3-time handshake protocol for TCP will be made, and after the TCP handshake protocol completes, the socket instance object will be created, or a IOException error will be thrown.

Working with Java I/o 2

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.