回答:
のマンページにnetstatは、各状態の簡単な説明があります。
ESTABLISHED
The socket has an established connection.
SYN_SENT
The socket is actively attempting to establish a connection.
SYN_RECV
A connection request has been received from the network.
FIN_WAIT1
The socket is closed, and the connection is shutting down.
FIN_WAIT2
Connection is closed, and the socket is waiting for a shutdown
from the remote end.
TIME_WAIT
The socket is waiting after close to handle packets still in the
network.
CLOSE The socket is not being used.
CLOSE_WAIT
The remote end has shut down, waiting for the socket to close.
LAST_ACK
The remote end has shut down, and the socket is closed. Waiting
for acknowledgement.
LISTEN The socket is listening for incoming connections. Such sockets
are not included in the output unless you specify the
--listening (-l) or --all (-a) option.
CLOSING
Both sockets are shut down but we still don't have all our data
sent.
UNKNOWN
The state of the socket is unknown.
状態遷移図(ここ、ここ、ここの例)を使用して、状態をよりよく理解できます。
ソケット接続を試みる2つのプログラムを考えてみてください(それらaを呼び出し、およびb)。両方ともソケットをセットアップし、LISTEN状態に移行します。次に、1つのプログラム(たとえばa)が他のプログラム()に接続しようとしbます。a要求を送信してSYN_SENT状態に入り、要求をb受信してSYN_RECV状態に入ります。場合はb、要求を認める、彼らが入るESTABLISHED状態を、そして彼らのビジネスを行います。今、いくつかのことが起こります:
a接続を閉じて、を入力しFIN_WAIT1ます。リクエストbを受信しFIN、ACK(をa入力してFIN_WAIT2)を送信し、エンターし、終了してCLOSE_WAITいるaこととエンターを通知しますLAST_ACK。一度aこれを認識し(と入力するTIME_WAIT)、b入りますCLOSE。a何かが残っているかどうかを確認するために少し待ってから入りCLOSEます。aそしてb彼らのビジネスを終え、接続(同時閉鎖を)閉じることを決定しました。ときaでありFIN_WAIT、その代わりに受信ACKからb、それが受信するFIN(としてb希望が同様にそれを閉じるために)、a入射しますCLOSING。しかし、そこに送信するにはまだいくつかのメッセージが(あるACKそのa元のために取得することになっているFIN)、これは一度ACK到着し、a入るTIME_WAITいつものように。