Sockets

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Sat Jun 29 13:59:14 AEST 1991


In article <564 at jahangir.UUCP> wayne at jahangir.UUCP (wayne) writes:
> 	Here's on for all you sockets fans out there. I have stream
> sockets. One process creates and binds to the socket. Another process
> connects to the socket.
> 	If something bad happens and both processes exit without closing
> the socket, is there a way to close the socket. The process that bound
> the socket has not properly closed it. And the reading process has died.
> In effect leaving a orphaned socket.

When a process dies, all its descriptors are closed. If every process
that had the socket open suddenly dies, the socket is closed.

I suspect that you're working with UNIX-domain sockets, and what you're
seeing is the useless socket file left after the server dies. You can
just remove it. If the socket was for meant for just that connection,
the server should remove the bound filename immediately after accept().
In any case it should make an effort to catch those ``bad'' things
happening and remove the socket before it exits.

---Dan



More information about the Comp.unix.questions mailing list