Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I do netstat -a on my Windows machine, I get a listing of the ports with one of the four states:

  • LISTENING
  • CLOSE_WAIT
  • TIME_WAIT
  • ESTABLISHED

What do CLOSE_WAIT and TIME_WAIT mean/indicate?

share|improve this question
    
    
see 'man netstat', scroll down to the state section: linux.die.net/man/8/netstat –  MaQleod Apr 10 at 18:26

2 Answers 2

up vote 59 down vote accepted

Due to the way TCP/IP works, connections can not be closed immediately. Packets may arrive out of order or be retransmitted after the connection has been closed. CLOSE_WAIT indicates that the remote endpoint (other side of the connection) has closed the connection. TIME_WAIT indicates that local endpoint (this side) has closed the connection. The connection is being kept around so that any delayed packets can be matched to the connection and handled appropriately. The connections will be removed when they time out within four minutes. See http://en.wikipedia.org/wiki/Transmission_Control_Protocol for more details.

share|improve this answer
3  
The weasel words "other side" and "this side" are confusing. Can we have this rewritten (correctly) with "source" and "destination" instead? –  ADTC Mar 12 at 8:11
13  
@ADTC No, because that wouldn't make sense -- TCP is full-duplex, either side can be the source or destination. The correct words would be "local endpoint" and "remote endpoint". –  Jonathon Reinhart Apr 28 at 1:03

Basically the "WAIT" states mean that one side closed the connection but the final confirmation of the close is pending.

See e.g. this diagram of TCP states for details:

http://www.jxos.org/Projects/TCP/tcpstate.html

share|improve this answer
5  
This accurately describes CLOSE_WAIT but not TIME_WAIT. TIME_WAIT indicates that the local application closed the connection, and the other side acknowledged and sent a FIN of its own. We're now waiting for any stray duplicate packets that may upset a new user of the same port. –  Chris Smowton Apr 10 at 12:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.