Since childhood, we have been taught TCP three handshake, four times wave.
In fact, textbooks limit our thinking to death, the reality of the situation is more interesting. For example, the server side will also actively "say hi", the client and the server side will also send a syn.
Bo Master summed up the following several machines for the TCP signal response to the so-called "client" and "server-side" are applicable.
Rules for establishing a connection:
1. Received SYN must reply Ack2. When a SYN is received in the listen state, an additional SYN, the SYN + ACK, is restored and converted to the SYN-RCVD State 3. Receive the SYN in the Syn-sent state, also to the SYN-RCVD state 4. Send SYN in Listen state, convert to Syn-sent State 5. Receive ACK under Syn-sent or SYN-RCVD, convert to established close connection rule: 1. Receive fin must reply Ack2. In Establishe D send fin after conversion fin-wait-13. After receiving an ACK in fin-wait-1, convert the fin-wait-24. Received after fin conversion time-wait5 under Fin-wait-2. Fin received at established After conversion close-wait, wait for all data to send fin after delivery, and then convert Last-ack State 6. Receive an ACK under conversion closing7.closing under Fin-wait-1 received under fin After conversion to time-wait8.time-wait wait timer expires (2MSL) after entering closed you can follow this figure a verification: three times handshake four times wave
Some humble opinions on TCP