How do I properly close a socket?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Why do we need sockets?

479


How many sockets can a cpu have?

496


Whats the difference between select() and poll()?

1206


What is a socket set used for?

501


Are sockets files?

499






What is difference between socket () and serversocket () class?

493


What's the difference between a socket and a port?

457


How do unix sockets work?

488


How can I set the timeout for the connect() system call?

1105


What pieces of information make up a socket?

540


Is socket a hardware or software?

503


What is a socket address?

516


How to find other end of unix socket connection?

508


What is a sae socket?

509


How can I force a socket to send the data in its buffer?

1093