Unix Socket Programming Question:

Download Job Interview Questions and Answers PDF

How do I properly close a socket?

Unix Socket Programming Interview Question
Unix Socket Programming Interview Question

Answer:

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.''.

Download Unix Socket Programming Interview Questions And Answers PDF

Previous QuestionNext Question
How do I get the port number for a given service?What is the difference between close() and shutdown()?