cURL / Mailing Lists / curl-library / Single Mail

curl-library

select error

From: Tom Jerry <catod6_at_gmail.com>
Date: Tue, 10 Oct 2006 10:55:50 +0200

Hello,
I'm using libcurl 7.15.5 under Win2k.
I'm using the multi interface, and have a separate thread for the multi
loop.
Whenever I "select" and there are no easy handles added to the multi handle
(for example, when the application starts and there are still no http
requests to send or when all requests are finished), I get an error (rc is
-1) and WSAGetLastError() returns 10022.

According to MSDN:
WSAEINVAL (10022) *Invalid argument*.Some invalid argument was supplied (for
example, specifying an invalid level to the *setsockopt* function). In some
instances, it also refers to the current state of the socket???for instance,
calling *accept*<http://msdn.microsoft.com/library/en-us/winsock/winsock/accept_2.asp>on
a socket that is not listening.
Does it seems to you like a normal behaviour of select or is there something
wrong with my code?

Here is a portion of my code:

    while(!_Terminated())
    {

        FD_ZERO(&fdread);
        FD_ZERO(&fdwrite);
        FD_ZERO(&fdexcep);
        maxfd = 0;

        /* set a suitable timeout to play around with */
        timeout.tv_sec = 1;
        timeout.tv_usec = 0;

        /* get file descriptors from the transfers */
        EnterCriticalSection(&curl_lock);
        /* we start some action by calling perform right away */
        while(CURLM_CALL_MULTI_PERFORM ==
            curl_multi_perform(m_multi_handle, &still_running));
        curl_multi_fdset(m_multi_handle, &fdread, &fdwrite, &fdexcep,
&maxfd);
        LeaveCriticalSection(&curl_lock);

        rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);

        switch(rc) {
        case -1:
            LogMessageEx (EVENTLOG_WARNING_TYPE, CAT_IP_MC, 0,
                "CHttpPollingThread::main() : select error,
WSAGetLastError=%d !!!",
                WSAGetLastError());
         ....
         ....
        .....

Thanks,
Ori.
Received on 2006-10-10