listen() discrepancy

stuart at rochester.UUCP stuart at rochester.UUCP
Thu Feb 13 22:48:02 AEST 1986


From: Stuart Friedberg  <stuart>

While doing some quick experiments to get a feel for the Berkeley
(nee BBN) IPC system, we noticed that the documentation and the
behavior for the listen() call are completely different.

The manual says pretty explicitly that listen(s, backlog) will permit
a maximum of "backlog" UNaccepted connections on socket "s" and says
nothing about the number of accepted connections.

The code actually implementing the check permits a maximum of
(backlog*3/2)+1 total connections, both unaccepted AND accepted.  This
is for both 4.2 and our copy of 4.3(beta).

Obviously, the code and the documentation aren't together.  There's at
least one reason to have the documented behavior: If a server isn't
accepting new connections, you want potential clients to know about it
by getting "connection refused" rather than waiting.  Giving a fixed
listen() backlog of 1 (or setting it to 0 when the server doesn't want
to answer the door)  minimizes the number of clients hanging around
waiting for service.

What I'd like to know is:
1) What the rationale for the implemented behaviour is.
     (Why do it this way?)
2) What would break if the code did the documented thing.
     (Why not fix it?)

Stu Friedberg  {seismo, allegra}!rochester!stuart  stuart at rochester



More information about the Comp.unix.wizards mailing list