Re: Passing sockets....

Joerg Pommnitz (Joerg@raleigh.ibm.com)
Thu, 27 Feb 1997 07:23:07 -0500


Richard B. Johnson wrote:
> A socket is a file-descriptor. The file-descriptor numbers go from 0 to
> N and are process-specific. In other words several tasks may have the
> same socket numbers which refer to different things. Therefore, even if
> you were to "give" the socket to another process, it couldn't have the
> same number. What you seem to need is a "socket server". It would
> communicate with your server via a pipe, shared memory, or another
> socket. Note that X11 communicates with the server via a socket.
>
> Suppose, instead of using many sockets in your server, you only used
> one. You posted a listen() and an accept() on localhost port xxxx.
> Your "socket-server" accepted multiple connections on the "real" network
> at whatever port you are using. The "socket-server" then just wrote
> incomming data to your server after a header that your socket-server
> added. It received data from your server using the same header which
> contained only the socket-server's socket number. The socket-server
> could then forward these data to the correct hosts because the header
> contained its socket number.

Nope. What he wants is to pass open file descriptors from one process
to another. This is possible with unix domain sockets. For an example
look in Stevens' "Advanced Programming in the UNIX environment".

--
Joerg Pommnitz   |Joerg@Raleigh.ibm.com| Never attribute to malloc 
Mobile/Wireless  |Dept UMRA            | that which can be adequately
T/L (919)254-6397|Office B502/E117     | explained by stupidity.