Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!ucbvax!decwrl!crltrx!decvax!testmax!evans From: evans@testmax.ZK3.DEC.COM (Marc Evans) Newsgroups: comp.unix.questions Subject: Re: unix domain sockets Message-ID: <6740@decvax.dec.com> Date: 23 Feb 90 12:09:26 GMT References: <1990Feb23.023047.19975@uniwa.uwa.oz> Sender: news@decvax.dec.com Reply-To: evans@decvax.DEC.COM Organization: Synergytics Lines: 36 In article <1990Feb23.023047.19975@uniwa.uwa.oz>, toivo@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@decvax.DEC.COM | Synergytics (603)893-8481 Unix/X-window Software Contractor | 3 Koper Ln, Pelham, NH 03076 ==========================================================================