socket connection establishment process

Establishing a Socket connection requires at least a pair of sockets, one of which runs on the client side, called ClientSocket, and the other on the server side, called ServerSocket. The connection process between sockets is divided into three steps: server monitoring, client request, and connection confirmation.

  1. Server monitoring: The server-side socket does not locate the specific client socket, but is in a state of waiting for connection, monitoring the network status in real time, waiting for the client's connection request
  2. Client request: The client's socket makes a connection request, and the target to be connected is the server-side socket. To this end, the client's socket must first describe the socket of the server to which it is connected, indicate the address and port number of the server-side socket, and then make a connection request to the server-side socket
  3. Connection confirmation: When the server-side socket listens to or receives the connection request of the client socket, it responds to the request of the client socket, creates a new thread, and sends the description of the server-side socket To the client, once the client confirms this description, the two parties formally establish a connection. The server-side socket continues to be in the listening state, and continues to receive connection requests from other client sockets
Published 162 original articles · praised 58 · 90,000 views

Guess you like

Origin blog.csdn.net/ThreeAspects/article/details/105568525