I presume that (x)inetd works like most daemons, in that when it accept()
s a connection on a port it's monitoring, a socket is created. Somehow, though, before it fork()
s and exec()
s the target service program, it manages to convert this bidirectional socket into the three standard I/O descriptors STDIN, STDOUT, and STDERR.
I've been asking around how to defeat this behavior without rolling my own version of inetd, with no success. It occurred to me to ask the question in this manner, because it might lend a clue as to how I might then re-"join" file descriptors 0, 1, and 2 into a single socket.
The reason for my wanting to have the service program communicate bidirectionally over a single socket is that it needs to use an I/O infrastructure that is based on a single, bidirectional socket.