Article directory
handshake process
- At the beginning, both the client and the server are in the CLOSE state. First, the server listens to a certain port and is in the LISTEN state.
- Then the client actively initiates a SYN connection, and then is in the SYN-SEND state.
- The server receives the initiated connection, returns SYN, and ACKs the client's SYN, and is then in the SYN-RECV state.
- After receiving the SYN and ACK sent by the server, the client sends an ACK of ACK, and then is in the ESTABLISHED state, because it successfully sent and received.
- After the server receives the ACK of the ACK, it is in the ESTABLISHED state because it has also successfully sent and received.
Common test points
- Why three handshakes instead of two?
Answer: Because when the received packet contains more than ACK, you need to reply with an ACK, otherwise a timeout and retransmission will occur. The server needs to receive the ACK sent by the ACK to establish a connection.
- Why three handshakes instead of four?
Answer: Because the server can also send SYN packets while sending ACK packets, the reason is that these two flags do not logically conflict.