[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Writing to multiple descriptors with one system call
On Thu, 18 Mar 2010 00:53:26 +0100
Jean-Yves Migeon <jeanyves.migeon%free.fr@localhost> wrote:
> On 03/17/10 17:53, Sad Clouds wrote:
> > 1. Accepting connections
> > On busy web server it is likely that the listening socket will have
> > multiple entries on the completed connection queue (i.e. established
> > state). You call accept() in a loop until you get EWOULDBLOCK and
> > since these are new connections, the chances are all these sockets
> > contain HTTP GET requests for /index.html
> > Instead of calling write() 50 times for all 50 new sockets, you
> > could just call write2v() once.
> So basically, between the 1st accept(2) and the last, all the clients
> are waiting for input (which they will get sequentially, when you
> will perform your write2v() after the _last_ accept(2)).
> Which means that the 1st "accepted" filedes created will wait for the
> 50th to be accepted. Seems inefficient for me.
This is what high performance servers do. There is nothing
"inefficient" about it. You set the listening socket non-blocking and
call accept() in a loop. Any connections that have completed 3-way
handshake will be on the socket's ready queue and will be returned to
you straight away.
Main Index |
Thread Index |