A TCP connection is a full-duplex connection. To understand the connection release, we can consider them to be a pair of simplex connections. We can then imagine that each simplex connection is being released independently. Releasing a TCP connection is symmetric. Either port can send a TCP segment with the FIN bit set, meaning it has no more information to send when the FIN is acknowledged that direction is shut down. Still, data can continue to flow continually in the other direction.
If a FIN response is not taken within two maximum packet lifetimes, the FIN's sender releases the connection. The receiver will ultimately notice that it gets no more data and time-out as well. Typically, four TCP segments are required to release a connection, i.e., one FIN and one ACK in each direction.
The steps involved in TCP connection establishment and release can be represented using a finite state machine. The 11 states in such a state machine are given in the table.
The table given below gives the different states in TCP Connection −
| Closed||There is no connection that is active or undecided.|
| Listen||The server is remaining for an incoming call.|
| SYN Received||A connection request has appeared. Wait for ACK.|
| SYN SENT||The application has initiated to open a connection|
| Established||The regular data transfer rate.|
| FIN wait-1||The application sender has finished.|
| FIN wait -2||The other side has agreed to wait for all packets to die off.|
| Timed Wait||It can wait for all packets to expire off.|
| Closing||Both sides have attempted to close simultaneously.|
| Close wait||The other side has proposed a release.|
| Last ACK||Wait for the ack of a fin of the previous close.|
In the above 11 states shown in the table, some specific events are legal. Corresponding to every event it may take some action, but if some other event happens, then the error is reported. The finite state machine is shown in the figure.