Explain the TIME_WAIT state.
Answer / chaitanya
Remember that TCP guarantees all data transmitted will be delivered, if at all possible. When you close a socket, the server goes into a TIME_WAIT state, just to be really really sure that all the data has gone through. When a socket is closed, both sides agree by sending messages to each other that they will send no more data. This, it seemed to me was good enough, and after the handshaking is done, the socket should be closed. The problem is two-fold. First, there is no way to be sure that the last ack was communicated successfully. Second, there may be "wandering duplicates" left on the net that must be dealt with if they are delivered.
| Is This Answer Correct ? | 1 Yes | 0 No |
What are the pros/cons of select(), non-blocking I/O and SIGIO?
What is with the second parameter in bind()?
What exactly does SO_KEEPALIVE do?
How can I read ICMP errors from connected UDP sockets?
What is LILO?
What are Sockets?
How should I choose a port number for my server?
Where is the socket located?
What is difference between socket and websocket?
Is there any advantage to handling the signal, rather than just ignoring it and checking for the EPIPE error? Are there any useful parameters passed to the signal catching function?
over the socket? Is there a way to have a dynamic buffer? What does one do when one does not know how much information is coming?
Why does it take so long to detect that the peer died?