home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!sunic!lunic!eru.mt.luth.se!enterpoop.mit.edu!think.com!sdd.hp.com!wupost!udel!princeton!tex.Princeton.EDU!subbarao
- From: subbarao@fc.hp.com (Kartik Subbarao)
- Newsgroups: comp.unix.programmer
- Subject: Re: Question on daemon's under inetd
- Message-ID: <1992Dec27.183029.2343@Princeton.EDU>
- Date: 27 Dec 92 18:30:29 GMT
- References: <1992Dec24.064005.5831@tigger.jvnc.net> <1992Dec24.161716.7183@Princeton.EDU>
- Sender: news@Princeton.EDU (USENET News System)
- Reply-To: subbarao@fc.hp.com
- Organization: putchar('I'); for (i = 0; i < 3; i++) putchar('E');
- Lines: 56
- Originator: news@nimaster
- Nntp-Posting-Host: tex.princeton.edu
-
- Once again, I must flame myself for a hastily submitted article (I had to
- get on a plane in 30 minutes)
-
- In article <1992Dec24.161716.7183@Princeton.EDU> I wrote:
- >In article <1992Dec24.064005.5831@tigger.jvnc.net> aggarwal@tigger.jvnc.net (Vikas Aggarwal) writes:
- >>? Can't I reuse the file descr 0 handed to me by 'inetd' ??
- >
- >You can't issue an accept() on a socket given to you by inetd.
- >
- >There are two different types of sockets at work here. One type of socket
- >is the one connected to the remote end of the connection. It is used as an
- >endpoint of communication, to which you can read and write arbitrary data.
- >
- >The other type, which I'll call a "server socket", is used to maintain a queue
- >of incoming connections from different hosts to that port. When you issue the
- >listen() call on a socket, it sets the SO_ACCEPTCON flag in it, thus enabling
- >you to accept() on that socket. Writing to or reading from this kind of
- >sockets is useless. The only purpose of this socket is to return you
- >another socket (from accept()) through which you CAN read and write to the
- >remote host.
- >
- >Inetd sets up a bunch of these server sockets on the well known ports. When
- >an incoming connection from another host is detected, accept() returns
- >a socket of the "normal" (read/write type) to inetd, and inetd gives you
- >this socket on fd's 0, 1 and 2.
-
- Everything up to here is correct.
-
- >Note, this socket is bound to a different TCP
- >port than the server socket, so that you can potentially have multiple remote
- >hosts accessing your service.
-
- This is bullshit. The reader socket is bound to the same port as the
- server socket. As far as the remote host is connected, it's the same
- connection. You can still have multiple remote connections accessing your
- service since the REMOTE port will be different for each connection.
-
- >Here's where the wait/nowait comes in. If you
- >specify wait in /etc/inetd.conf, inetd will NOT allow multiple instances of
- >your daemon to run. That is, it will wait until the process is terminated
- >before it forks off another instance. If you specify nowait, then it will
- >fork off as many requests as it can handle, without waiting for any of them
- >to finish. Once again, the socket that inetd returns to you is a normal
- >read/write socket, so you cannot accept() on it, even after the connection is
- >closed.
-
- This is correct.
-
- >Even if you could, it would be useless, since it is not bound to the
- >well-known port.
-
- This is wrong, just as before.
-
- Sorry 'bout that folks. Happy holidays! :-)
-
- -Kartik
-