|
From: Jack O'Q. <jac...@gm...> - 2008-12-24 03:24:09
|
On Tue, Dec 23, 2008 at 8:27 PM, Stephen Sinclair <rad...@gm...> wrote: > On Tue, Dec 23, 2008 at 4:46 PM, Steve Harris > <S.W...@ec...> wrote: >> On 23 Dec 2008, at 19:03, Stephen Sinclair wrote: >>> Maybe Steve H. can tell me, but I'm not actually sure what advantage >>> poll() has over select(), actually. >> >> Not really my field, but I used to work without shouting distance of a >> load of network research people, I asked them and they said "use >> poll(), it's better" or words to that effect :) >> >> I vaguely remember that select is only efficient with a small number >> of sockets/FDs. > > > Hmm.. :) Interesting, I personally haven't used poll before at all. > I looked into it, as I got curious. It looks like select() is > basically limited in number of sockets because it uses a bitmask. > > Looks like it wasn't necessary before, but if I'm to maintain a list > of sockets it works well. I can probably save some coding by using an > array instead of a linked list and pass it in directly. (I was trying > to avoid shuffling array items around, but now that I think about it, > it's probably a lot more efficient to shuffle an array when > connections are removed, than to build it from a list every time > lo_server_recv() is called.) > > I think for portability I might change it to use autoconf to detect > poll() and use it, instead of just assuming it is there on non-Windows > systems. I generally use poll() because it comes from the POSIX standard. Someone recently pointed out to me that POSIX now specifies select() as well. That was originally a BSD interface (IIRC). I think both are probably OK for most purposes. Poll still seems slightly better because it handles processes with >32 open files. -- joq |