unix domain sockets
Marc Evans
evans at testmax.ZK3.DEC.COM
Fri Feb 23 23:09:26 AEST 1990
In article <1990Feb23.023047.19975 at uniwa.uwa.oz>, toivo at uniwa.uwa.oz
(Toivo Pedaste) writes:
>
> When a unix domain socket is opened by a server program
> it is created in the file system, but when the server program closes
> it and exits it continues to exist. Now when a client program
> is run it get an error saying that the socket is not connected,
> while when the server is run it gets an address already in use
> error.
>
> My question is does this now orphaned socket have a
> possible use or does it just get in the way.
This type of problem is typically due to the socket not being properly
setup and
closed down. After calling socket, it is often recommended that a call be made
to setsockopt something like the following:
setsockopt(fd,SOL_SOCKET,SO_REUSEADDR,NULL,0);
This will allow the address to be reused.
The shutdown function is also recommended, such that anytime either side of the
connection decides that it is done reading/writing, it is called to
indicate so.
Often, a signal catcher is useful to help with this, so that the
exception cases
are handled in a defined maner (such as cntl-c).
Now, to answer your question, for most purposes, the "orphaned socket" is of no
use to anybody, and should be removed when it is no longer in use.
- Marc
==========================================================================
Marc Evans - WB1GRH - evans at decvax.DEC.COM | Synergytics (603)893-8481
Unix/X-window Software Contractor | 3 Koper Ln, Pelham, NH 03076
==========================================================================
More information about the Comp.unix.questions
mailing list