>I am currently writing a couple of servers that are started by inetd. I am
>using a SunSparc II (SunOS 4.1.2).
>Having read UNIX Network Programming, by W. Richard Stevens, it says (pp
>336-337) that for a stream socket, inetd does a select() and then an
>accept().
>Believing this to be true, I wrote my server. And then spent hours wondering
>why it didn't work.
>Eventually, I tracked it down to the descriptors I inherited. It turns out I
>have to accept() on the socket I get passed.
>Is this an error in the book (and another piece of documentation I have, A
>Network Primer, but this does seem to be based heavily on Steven's book),
>or just a peculiarity of Sun's implementation?
No, you just put the wrong entry for your type of server in /etc/inetd.conf.
There are two possible types of tcp services that can be defined in
/etc/inetd.conf. The services with the nowait keyword. This
is the normal type of service as described in the book you mention.
This is the ``nowait'' type of service. In that case inetd will do the
accept and hand you the connected sockets. Examples are:
telnetd, rlogind, fingerd, etc etc.
For each client a new single client serving program is started.
e.g.:
telnet stream tcp nowait root /usr/etc/in.telnetd in.telnetd
The second type is the tcp service with the ``wait'' keyword. Only
for the first client the server is started. The server gets the
listening socket, otherwise it wouldn't be able to accept() more
than one client. In this case the server will serve a number of
clients at the same time.
I know no examples of this.
I assume you specified the wait keyword in /etc/inetd.conf whe you should
have specified the nowait keyword.
Casper