curl-library
Re: select error
Date: Wed, 11 Oct 2006 21:52:51 +0100
Tom Jerry wrote:
> FD_ZERO(&fdread);
> FD_ZERO(&fdwrite);
> FD_ZERO(&fdexcep);
>
> /* set a suitable timeout to play around with */
> timeout.tv_sec = 1;
> timeout.tv_usec = 0;
>
> /* get file descriptors from the transfers */
> curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
>
> if ((maxfd != -1))
> {
> rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
> }
> else
> {
> #ifdef WIN32
> Sleep(timeout.tv_sec*1000);
Shouldn't that be:
Sleep(timeout.tv_sec * 1000 + (timeout.tv_usec + 999) / 1000);
> #else
> select(0, NULL, NULL, NULL, &timeout);
> #endif
> rc = 1;
> }
Microsoft's documentation for select() says:
"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.
The last sentence implies that every empty descriptor set must be
given as a null parameter, rather than the non-null address of an
empty descriptor set.
Yet, presumably the code works find on Windows.
I wonder if that's a bug in Microsoft's documentation, or an problem
with your code which may trigger on some versions of Winsock?
Curiously,
-- Jamie
Received on 2006-10-11