650) this.width=650; "src=" http://img.blog.csdn.net/20140918171436188 "alt=" 20140918171436188 "/>
SYN: (Synchronous sequence number, Synchronize Sequence Numbers) This flag is valid only if the three-time handshake establishes a TCP connection. Represents a new TCP connection request.
ACK: (acknowledgement number) is a confirmation flag for the TCP request and indicates that the peer system has successfully received all the data.
FIN: (end sign, finish) used to end a TCP reply. However, the corresponding port is still open and ready to receive subsequent data.
1), LISTEN: First, the server needs to open a socket for monitoring, the status of LISTEN. /* The socket is listening for incoming connections. Listening for connection requests from remote TCP ports */
2), Syn_sent: The client calls connect through the application to make active open. The client TCP sends a SYN to request a connection. The state is then set to Syn_sent. /*the socket is actively attempting to establish a connection. Wait for a matching connection request after sending a connection request * /
3), SYN_RECV: The server should issue an ACK to confirm the client's SYN, and send itself to the client a syn. The status is then set to SYN_RECV /* A connection request has been received from the network. Wait for confirmation of connection request after receiving and sending a connection request */
4), established: represents an open connection, both can be made or have interacted with the data. / * The socket has an established connection. Represents an open connection where data can be delivered to the user * /
5), Fin_wait1: Active shutdown (active close) end application calls Close, and its TCP sends a FIN request to actively close the connection and then into the fin_wait1 state. /* The socket is closed, and the connection are shutting down. Waits for a connection interrupt request from a remote TCP, or a confirmation of a previous connection interrupt request */
6), close_wait: Passive shutdown (passive close) After TCP receives FIN, an ACK is issued in response to the FIN request (its receive is also passed as a file terminator to the upper-level application) and enters the close_wait. / * The remote end has a shut down and waiting for the socket to close. Waiting for a connection interrupt request from a local user * /
7), Fin_wait2: Active closed end received ACK, entered the fin-wait-2. / * Connection is closed, and the socket was waiting for a shutdown from the remote end. Waiting for a connection interrupt request from TCP * /
8), Last_ack: After a period of passive shutdown, the application that receives the file terminator will call close to close the connection. This causes its TCP to also send a FIN, waiting for the other person's ACK. It went into the last-ack. / * The remote end has a shut down, and the socket is closed. Waiting for acknowledgement. Wait for the acknowledgement of the connection interrupt request that was originally sent to remote TCP * /
9), Time_wait: After the active shut-off side receives the fin, TCP sends the ACK packet, and enters the time-wait state. / * The socket is waiting after close to handle packets still in the network. Wait enough time to make sure that the remote TCP receives a connection interrupt request confirmation * /
10), CLOSING: Both sides close the transmission at the same time, relatively rare. / * Both sockets is shut down but we still don't have any of our data sent. Wait for the remote TCP acknowledgement of the connection interruption * /
11), CLOSED: Passive closed end after receiving the ACK packet, it entered the state of CLOSED. End of connection. / * The socket is not being used. No connection status * /
The formation of the TIME_WAIT state occurs only on the side of the active shutdown connection.
TCP/IP finite state machine