[ee122] accept() blocks too much...

Richard Schmidt huntingtonsurfca at gmail.com
Thu Sep 20 23:33:23 PDT 2007

Ok a couple of things to point out that I've agonized over:

There is such a thing as FD_SETSIZE
It will only bring you much misery and isn't the cure-all you're looking
for. Everywhere I used it (another website suggested its use as it
supposedly returns the max-size for the fd_set which seemed like a hack for
doing max all the time) it cuased bugs in my server code.

Also. select() will only check up to N-1 socket descriptors. So don't pass
it N. I can't make it clearer besides saying look at beej's code for
multi-user sessions and select().

I hope I've made the path easier to tread for those that are starting this
weekend (you think I'm kidding...?).


On 9/20/07, Vern Paxson <vern at icir.org> wrote:
> > I'm running select() and the listening port is returning that it's ready
> to
> > add a new connection, but then it'll say it's ready even though there
> are no
> > pending connections
> This pretty much has to be a bug somewhere in your code, since the
> semantics are indeed that if select() shows activity on a listen socket,
> then a single call to accept will retrieve a new connection from it.
> A zillion servers out there rely on exactly this ...
> > Server is hung on accept()
> You should use a debugger such as gdb to verify that select() really is
> showing that the descriptor you're passing to accept() has activity.
>                Vern
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ICSI.Berkeley.EDU/pipermail/ee122/attachments/20070920/f88e4e2d/attachment.html 

More information about the ee122 mailing list