cURL / Mailing Lists / curl-library / Single Mail

curl-library

Fwd: How can i get socket fd from multi_curl ?

From: huancong deng <denghuancong_at_gmail.com>
Date: Fri, 2 Nov 2012 21:45:41 +0800

---------- Forwarded message ----------
From: huancong deng <denghuancong_at_gmail.com>
Date: Fri, Nov 2, 2012 at 7:17 PM
Subject: How can i get socket fd from multi_curl ?
To: curl-tracker_at_cool.haxx.se

here is my code , I want to get the socket fd from curl_multi_fdset
function, but is it right ? who can tell me about this??? thanks a lot.
====================================================================================================
   map<int, uint32_t> mapFDEvents;
   res = curl_multi_perform(args->multi_curl, &running_handles);
   curl_multi_fdset(args->multi_curl, &fdread, &fdwrite, &fdexcep, &maxfd);
    g_sInterface.log_write(3, "AIOCURL:maxfd:%u", maxfd);
    for ( int i = 0;i < __FD_SETSIZE / __NFDBITS;i++ ) {
        for ( int j = 0;j < __NFDBITS;j++ ) {
            int fd = i * __NFDBITS + j;
            if ( __FDS_BITS(&fdread)[i] & (1 << j) ) {
                mapFDEvents[fd] = EPOLLIN;
            }
            if ( __FDS_BITS(&fdwrite)[i] & (1 << j) ) {
                if ( mapFDEvents.find(fd) == mapFDEvents.end() ) {
                    mapFDEvents[fd] = EPOLLOUT;
                }
                else {
                    mapFDEvents[fd] |= EPOLLOUT;
                }
            }
        }
    }

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-11-02