LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   How do I close sockets? (https://www.linuxquestions.org/questions/linux-networking-3/how-do-i-close-sockets-586213/)

DittoAlex 09-20-2007 08:28 PM

How do I close sockets?
 
Let's say a p2p program dies badly and leaves a few hundred sockets hanging on CLOSED_WAIT. How do I kill them?

I know about close() and socket(), but it appears those commands can only be used from within a script/program.

How can I accomplish this at a bash prompt?

zidane_tribal 09-21-2007 06:18 AM

basicly, you dont, you just wait a while. p2p apps use *masses* of sockets, what you are seeing are "half closed" sockets. one end has sent the fin and asked for the socket to be closed down, its just waiting on the other end to agree and close the socket. if one of the ends fails to reply (i.e. you kill your end, or the client kills their end), then the socket hangs around on a close_wait state. eventually it will time out, and linux will just figure out the other end got lost and drop the socket naturally.

dont worry about seeing enormous numbers of them from p2p applications, due to the large numbers of clients constantly connecting and disconnecting, a lot of sockets get "lost in the cracks" so to speak. your p2p program *should* clean up its sockets when it quits, but a lot just plain dont.

DittoAlex 09-21-2007 08:06 AM

I take it it's impossible. Thanks.


All times are GMT -5. The time now is 12:07 PM.