How do I properly close a socket?



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

Post New Answer

More Unix Socket Programming Interview Questions

How come select says there is data, but read returns zero?

1 Answers  


How do unix sockets work?

0 Answers  


What pieces of information make up a socket?

0 Answers  


system choose one for me on the connect() call? Should I bind() a port number in my client program, or let the?

0 Answers  


How do I send [this] over a socket?

1 Answers  






What is a deep well socket?

0 Answers  


How many socket connections can a server handle?

0 Answers  


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?

0 Answers  


How is a socket created?

0 Answers  


What is socket address?

0 Answers  


What is a socket set used for?

0 Answers  


When will my application receive SIGPIPE?

1 Answers  


Categories