http://blog.csdn.net/zuyi532/article/details/7599766
1, TCP three times the role of shaking hands:
The purpose of the three handshake is to connect the server to the specified port, establish a TCP connection, and synchronize the serial number and confirmation number of both sides of the connection and exchange the TCP window size information. In socket programming, when the client executes connect (), the handshake is triggered three times.
2, TCP three times handshake process:
The first step: The client sends a SYN-bit TCP message to the server that contains the initial serial number x of the connection and a window size (representing the size of the buffer on the client to store incoming segments sent from the server). --syn Message Segment
Second step: The server receives the client sends the SYN message, takes out the Tcp_syn message segment, assigns the TCP cache and the variable for this TCP connection, and sends to the client a SYN and the ACK to place the TCP message, which contains its choice initial serial number Y, to the client's serial number confirmation x+ 1 and a window size (representing the size of the buffer on the server that is used to store incoming segments sent from the client). --synack Message Segment
The third step: after receiving the Synack message segment, the client assigns the cache and variable to the connection, and returns a confirmation number Y+1 ACK message to the server side, the SYN bit in the message is placed 0, a standard TCP connection completes. (will be set to 0 in future message segments)