Passing file descriptors

Passing file descriptors

Post by Raphael Iglesi » Wed, 02 Oct 1996 04:00:00



I made a concurrent TCP server. The father forks a child when a client
connection is accepted. My application works fine and without problems.
But, there are always buts, I want to change this.
The idea it's to avoid the fork when a connection arrives. I wnat to
fork all my childs before the server startup and then when a connection
arrive pass the file descriptor of the socket to one of my free childs.
I did it but I can only call a child one time. The second time, I use
sendmsg() and recvmsg(), It's seems that de file descriptor's table of
my child don't be modified. Why? I don't know.
Somebody knows if there some reason? I don't have any error ( errno ),
the send and receive are OK.
Thanks and excuse my english I'm argentinian working in France.

 
 
 

Passing file descriptors

Post by W. Richard Steve » Thu, 03 Oct 1996 04:00:00


Quote:> I made a concurrent TCP server. The father forks a child when a client
> connection is accepted. My application works fine and without problems.
> But, there are always buts, I want to change this.
> The idea it's to avoid the fork when a connection arrives. I wnat to
> fork all my childs before the server startup and then when a connection
> arrive pass the file descriptor of the socket to one of my free childs.

The NCSA httpd server does exactly this.  Fetch the source code and take
a look at it.  But in some benchmarking that I've done, the techinque
used by the Apache server is even faster: it also preforks some number
of children and then each child calls accept() (with possible locking for
some SVR4 implementations).

        Rich Stevens