650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/80/F2/wKioL1dFX-CQ6KS0AAGDXqxE7S8065.png "title=" Tcp.png "alt=" Wkiol1dfx-cq6ks0aagdxqxe7s8065.png "/>
1, the client sends the request connection message (SYN=1,SEQ=CLIENT_ISN), the syn=1 indicates the request connection, the SEQ serial number randomly generates
2, the service side receives the request, replies the ACK message, the ACK is the source Seq=client_isc +1, in order to reply to the client to know own request received the reply
3, the client Reply ACK message confirmation establishes the connection, the ACK message is the service side Seq=server_isc +1
Four waves (disconnection process)
1, assume that the disconnection process by the client, then the client sends FIN message, meaning "My clinet client no data to send to you, I want to disconnect", the status becomes (FIN_WAIT1) the application will not immediately close the socket, if there is no data passed can continue to pass
2, the service side received fin message, send an ACK, said "Your request I know, but I'm not ready, please wait for my message"
At this point the server state changes to (CLOSE_WAIT), the client receives a status of (Fin_wait1), and the server continues to transmit data
3, such as service end is busy, will send fin message to the client, said "I am too busy, can be disconnected" status changed to (Last_ack)
4, the client received the disconnection fin message, will know to shut down the network, but he still does not believe the network, will send an ACK again to the server, the service side will know can be disconnected, and then close the connection, and the client is waiting for 2MSL (life cycle) about 1~ If you do not receive a response after 4 minutes, you will be actively shutting down the socket to close the connection.
TCP protocol three handshake, four waves