jgm@K.GP.CS.CMU.EDU (John Myers) (03/10/88)
In article <47@kenobi.UUCP> ford@kenobi.UUCP (Mike Ditto) writes: >In article <997@PT.CS.CMU.EDU> jgm@K.GP.CS.CMU.EDU (John Myers) writes: >> [...] >> Then why the heck can't you open(2) a BSD unix domain socket? [...] > >The main reason that I see is that a Unix domain socket is not really >supposed to show up in the filesystem, and it supposedly doesn't in >more recent BSD releases (4.3?). I don't think it has ever been clear >whether the "Unix domain" of socket names(addresses) is really >supposed to map into pathnames in the ("open"able) filesystem. Is it >possible to bind an AF_UNIX socket to "/foo/bar/baz" if there is no >directory "/foo"? [...] On a 4.3 system (IBM RT/PC), I tried binding an AF_UNIX socket to "/foo/bar/baz" and got ENOENT. I was also able to bind a socket to "//tmp/foo" and connect to it by specifying "/tmp/foo". I don't see why sockets shouldn't be in the filesystem. They can be read from and they can be written to. That's more than can be said for some of the things in /dev. If they could be opened, they would be almost as useful as System V named pipes. >> Something that would be harder, but would still be incredibly useful >> would be to automaticly unlink a socket when the (last) process owning >> that socket exits. > >That would be inconsistent with files, which are not unlinked under those >circumstances. [...] Yes, this is inconsistent. The problem I am addressing is that when a process binds a UNIX domain socket and then exits, there is this useless zombie socket which gets left behind. Attemting to bind to it gets EADDRINUSE. Attempting to connect to it gets ECONNREFUSED. The only reasonable thing that one can do with it is unlink it. Perhaps a more reasonable behavior would be to have a bind to an existing socket address succeed if no process owns a socket with that address. -- John G. Myers jgm@k.gp.cs.cmu.edu
ron@topaz.rutgers.edu (Ron Natalie) (03/17/88)
The problem is that when a UNIX socket creates a socket INODE they become visible but are completely useless. At one time I made a slight hack to 4.2 so that when you open a socket inode you get "connected" to the person doing the listen. I didn't get the code to remove the dead sockets though. -ROn