How do I properly close a socket?
Answer / chaitanya
This question is usually asked by people who try close(), because they have seen that that is what they are supposed to do, and then run netstat and see that their socket is still active. Yes, close() is the correct method. To read about the TIME_WAIT state, and why it is important, refer to ``2.7 Please explain the TIME_WAIT state.''.
| Is This Answer Correct ? | 0 Yes | 0 No |
Why do not my sockets close?
What are the types of sockets?
What is with the second parameter in bind()?
How can I put a timeout on connect()?
What is a socket set used for?
Why do we need sockets?
Whats the difference between select() and poll()?
If bind() fails, what should I do with the socket descriptor?
How can I listen on more than one port at a time?
How come only the first part of my datagram is getting through?
How do I use TCP_NODELAY?
How can I be sure that UDP messages are received in order?