Scoket flowchart: three handshakes of TCP in the socket to establish a connection flowchart: it can be seen that when the client calls connect, a connection request is triggered and a syn j packet is sent to the server, at this time, connect is blocked. The server listens to the connection request, that is, it receives the syn j packet and calls the accept letter to receive the request and sends the syn k, Ack J + 1, at this time, the accept enters the blocking status. After the client receives the syn k, Ack J + 1 from the server, connect returns the result and confirms the syn k. When the server receives the ACK k + 1, accept is returned. The three handshakes are completed and the connection is established. Conclusion: the client's connect returns the second time of the three-way handshake, while the server's accept returns the third time of the three-way handshake. The four handshakes of TCP in the socket to release the connection flowchart:
- An application process first calls close to close the connection, and TCP sends a fin m;
- After receiving the fin m, the other end performs passive shutdown to confirm the fin. Its receipt is also passed to the application process as a file Terminator, because the receiving of fin means that the application process can no longer receive additional data on the corresponding connection;
- After a period of time, the application process receiving the file Terminator calls close to close its socket. As a result, TCP also sends a fin N;
- The source sending end TCP that receives the fin confirms it.
In this way, there is a fin and ACK in each direction.
Scoket understanding Flowchart