Re: Bug in 2.1.119 UNIX sockets

Christoph Rohland (hans-christoph.rohland@sap-ag.de)
09 Sep 1998 14:07:12 +0200


Elliot Lee <sopwith@redhat.com> writes:

> When run on 2.0.33, this program always hangs, because it is trying to
> connect to its own socket. This is probably the Right Thing.
>
> When run on 2.1.119, this program completes the run successfully. The
> first time, the connect() (on a blocking fd) succeeds even before the
> connection is accept()'d. In subsequent runs, the bind to the address
> fails with EADDRINUSE, until I manually 'rm -f' the socket file.
>
> Both behaviours (succeeding connect, failing bind) seem erroneous.
> Demonstration program attached.

They are both quite ok.

The connect behaviour changed in 2.1.106 to behave like INET-sockets,
which also succeed when the OS accepted the connection but not the
application. (This is the backlog parameter for listen(2). BTW this
parameter does not work til now in Linux since it simply accepts
infinite connections). This behaviour is necessary to be able to
connect to yourself without nonblocking connect.

The bind behaviour did not change and is working this way on all
implementations I know. I cite 'Richard W. Stevens: Unix Network
Programming 2.edt' p375:

... But the bind will fail if the pathname already exists in
the filesystem.

Cheers
Christoph

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/faq.html