tadeusz
tadeusz

Reputation: 366

What is the state of a TCP socket after remote closed?

Say I have accepted() a connection to my server (that runs on a Solaris) and the client has closed the connection. What is the state of the socket (in netstat categories) of the socket on the server side before I close() it on the server side? Is it BOUND?

Upvotes: 0

Views: 3572

Answers (5)

xichen
xichen

Reputation: 351

CLOSE_WAIT

you can check by:

ps auxf

lsof -a -p [server_process_id]

you will get: sock 0,8

state 8: TCP_CLOSE

Upvotes: 0

user595997
user595997

Reputation: 1

It should be CLOSE_WAIT since the end which intiates FIN goes to TIME_WAIT ---> CLOSED first.

In this it's the client which initiates first. So the server will go to CLOSE_WAIT.

Upvotes: 0

Len Holgate
Len Holgate

Reputation: 21644

In this situation the socket on the client will be in TIME_WAIT and the socket on the server will go through CLOSE_WAIT and will move to CLOSED pretty quickly so you might not catch it in netstat before it vanishes from the list altogether.

Upvotes: 1

Anders Westrup
Anders Westrup

Reputation: 825

It will be CLOSE_WAIT, see the tcp state diagram, e.g. on http://en.wikipedia.org/wiki/File:Tcp_state_diagram_new.svg

Upvotes: 7

Seika
Seika

Reputation: 169

I guess, TIME_WAIT.

You may check it with "netstat" on Linux, don't know how do it on Solaris.

Upvotes: -1

Related Questions