What is socket)

Source: Internet
Author: User
When the application layer uses the transport layer for data communication, TCP and UDP may encounter concurrent services for multiple application processes at the same time. Multiple TCP connections or multiple application processes may need to transmit data through the same TCP port. To differentiate different application processes and connections, many computer operating systems provide interfaces called Sockets for applications to interact with TCP/IP protocols, differentiate network communication and connections between processes of different applications. Generate a socket with three parameters: the destination IP address for communication, the transport layer protocol (TCP or UDP) used, and the port number used. The original intention of socket is "socket ". By combining these three parameters and binding them with a "socket" socket, the application layer can distinguish communications from processes or network connections of different applications through the socket interface with the transport layer, implements concurrent data transmission services. The socket can be seen as an endpoint in the communication connection between two programs. One program writes a piece of information into the socket, and the socket sends this information to another socket, this information can be transmitted to other programs. 1: program a on host a writes a piece of information into the socket. The socket content is accessed by the network management software of host, the information is sent to host B through the network interface card of host a. The network interface card of host B receives the information and sends it to the network management software of host B, the Network Management Software saves this information in the socket of host B, and then program B can read this information in the socket. To communicate over the Internet, at least one socket is required. One is run on the client, called clientsocket, and the other is run on the server, called serversocket.
Based on the connection start method and the target to which the local socket is to be connected, the connection process between sockets can be divided into three steps: server listening, client request, and connection confirmation.
Server listener: A server socket does not locate a specific client socket, but is waiting for a connection. It monitors the network in real time. Client request: a connection request is initiated by the client socket. The target is the socket on the server. Therefore, the client socket must first describe the socket of the server to be connected, point out the address and port number of the socket on the server, and then submit a connection request to the socket on the server. Connection Confirmation: when the server socket listens to or receives a connection request from the client socket, it establishes a new thread in response to the request from the client socket, send the description of the server socket to the client. Once the client confirms the description, the connection is established. The server socket continues to be in the listening status, and continues to receive connection requests from other client sockets.

What is socket)

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.