From: Christopher Kohlhoff (chris_at_[hidden])
Date: 2006-01-03 07:26:15
--- Andrew Schweitzer <a.schweitzer.grps_at_[hidden]> wrote:
> Select is passed a list of all active sockets plus a special,
> "dummy" socket. Select_reactor, via a
> socket_select_interrupter object, is both client and server on
> this special dummy socket.
On posix platforms this is a pipe, rather than a socket.
Otherwise your statements seem correct.
> Assuming all of that is correct, can you explain what the code
> in socket_ops::select() does that checks if all sockets are
> null and if so calls ::Sleep()?
To make select on Windows behave like select on other platforms
> I sort of expect I've missed something, but it looks like dead
> code. with the prescence of the interrupter and its dummy
> socket, the socket list will never be null. Also, if they were
> null, I'm not sure Sleep would work very well. For one thing,
> it's not interruptable, so if the only thing is a large timer,
> any new additions of sockets or timers would have to wait for
> the large timer to complete before they could be added. For
> another, it looks like if there were no timers running, it
> would essentially be polling 1/ms for sockets + timers.
The socket_ops::select() function is also used to implement the
blocking deadline_timer::wait() operation, which doesn't pass
any sockets to select at all.
But in terms of the select_reactor, you're right that the
particular code path isn't used (and in fact the compiler ought
to be able to easily optimise it out).