Subj : Re: Threading and Timeouts To : comp.programming.threads From : Giancarlo Niccolai Date : Tue Jul 26 2005 10:41 am Charles Bryant wrote: > In article <42de49df$0$70709$e4fe514c@news.xs4all.nl>, > Casper H.S. Dik wrote: >>Giancarlo Niccolai writes: >> >> >>>Select works with WinSocks too, although with a couple of minor, >>>irrelevant differences (i.e. the first parameter, that is, maxfd + 1, is >>>ignored). >> >>That's not really a irrelevant difference; the caller of select is >>free to put garbage in the sets past the index of maxfd. > > There's another very relevant difference. From: > > en-us/winsock/winsock/select_2.asp > > > ! Any two of the parameters, readfds, writefds, or exceptfds, can be given > ! as null. At least one must be non-null, and any non-null descriptor set > ! must contain at least one handle to a socket. > > This is very non-intuitive and a considerable nuisance. It means that if > you have a program where you need to accommodate a varying number of > sockets being used with select(), you need to have special handling for > the cases where there happen to be no sockets currently in each of the > sets. It also means that the common idiom to get a microsecond-resolution > pause: > select(0, 0, 0, 0, x) > breaks on Windows. Yes, indeed this is really a nuisance. GN. .