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 |
How do I get my server to find out the clients address / host- name?
How come select says there is data, but read returns zero?
What is a socket set used for?
What exactly does SO_KEEPALIVE do?
Why do I get connection refused when the server is not running?
What is a sae socket?
What are the pros/cons of select(), non-blocking I/O and SIGIO?
How do Sockets Work?
Is tcp or unix socket faster?
Explain the TIME_WAIT state.
How can I set the timeout for the connect() system call?
Can a socket have multiple ports?