Connection State As Known by TCP

The TCP layer in the host at each end of a TCP connection keeps its own variable containing the state of the connection, using the connection states defined in RFC 793. This is the state shown in NETSTAT output.

Ignoring state transitions, which do not tend to conform to these simplistic definitions, the following table lists the connection states and what each typically implies about the state of the connection. See section 3.2 of RFC 793 for more information on connection states.

Table 1. TCP Connection States
State name Typical Situation
LISTEN Waiting for a connection request from the address and port listed in the Foreign Socket column of NETSTAT.
  • HOSTA..* means waiting for a connection request from any port on host HOSTA.
  • *..100 means waiting for a connection request from port 100 on any host.
  • *..* means waiting for a connection request from any port on any host.

If the application uses the Pascal interface or VMCF interface, it has done a TcpOpen (or TcpWaitOpen) with an initial pseudo-state of LISTENING.

If the application uses the socket interface, from C or via IUCV, it has done a listen(), and the listen backlog has not been reached.

SYN-SENT The application has done an active open and is waiting for a response from the foreign server.

If the application uses the Pascal interface or VMCF interface, it has done a TcpOpen (or TcpWaitOpen) with an initial pseudo-state of TRYINGtoOPEN.

If the application uses the socket interface, from C or via IUCV, it has done a connect().

SYN-RECEIVED Represents a condition where TCP is waiting for a confirming connection request acknowledgement after having received and sent a connection request. This sometimes means that a SYN was received on a connection in LISTEN state, but connection establishment hasn't been able to proceed further because a routing problem prevents the response from reaching the foreign host.
ESTABLISHED Connection is completely established. Both sides can send and receive data. This is the normal state for the data transfer phase of a connection.
FIN-WAIT-1 Application has issued a TcpClose or close(). A FIN packet was sent but not acknowledged, and a FIN hasn't been received from the foreign host.
FIN-WAIT-2 Application has issued a TcpClose or close(). FIN packet was sent and has been acknowledged. TCP is now waiting for the foreign host to send a FIN.

This is the state a connection enters when the application closes but the application on the other end doesn't close. There is no timeout in this state, since the FIN has been acknowledged.

If the foreign host sends an ACK packet in response to the the local host's FIN and then goes away without sending an RST, or if the RST is lost, then the connection will stay in this state for an indefinite period of time (until the application aborts the connection or terminates).

In this state, data can be received but not sent. Some applications may intentionally put the connection into this state because they plan to send data in one direction. However, in most cases, this is not a long-term state. Usually, persistence of this state indicates an error condition.

CLOSE-WAIT The local host has received a FIN from the foreign host and has acknowledged it, but the application hasn't issued a TcpClose or close().

In this state, data can be sent but not received. Some applications may intentionally put the connection in this state because they plan to send data in one direction. However, in most cases, this is not a long-term state. Usually, persistence of this state indicates an error condition.

CLOSING Represents waiting for a connection termination request acknowledgement from the remote TCP. This state (and the LAST-ACK state) indicates that both sides have closed the connection. Data cannot be sent in either direction.
LAST-ACK Represents waiting for an acknowledgement of the connection termination request previously sent to the remote TCP (which included an acknowledgement of the remote TCP's connection termination request). This state (and the CLOSING state) indicates that both sides have closed the connection. Data cannot be sent in either direction.
TIME-WAIT Both sides have closed the connection, and all packets have been acknowledged. The connection stays in this state for 2 * MSL (MSL = 60 seconds) as required by the protocol specification, to ensure that foreign host has received the acknowledgment of its FIN.

In VM TCP/IP, connections in TIME-WAIT state do not usually appear in the output from the NETSTAT command. The ALLCONN or TELNET parameters must be supplied on the NETSTAT command to see connections in this state.

CLOSED The connection is completely closed.

In TCP/IP for VM, connections in CLOSED state do not usually appear in the output from the NETSTAT command. The ALLCONN parameter must be supplied on the NETSTAT command to see connections in this state.