cURL / Mailing Lists / curl-library / Single Mail

curl-library

a curl_multi_fdset() replacement? (TODO-RELEASE #55)

From: Daniel Stenberg <daniel-curl_at_haxx.se>
Date: Mon, 31 Jan 2005 00:36:15 +0100 (CET)

Hi

In order to completely get rid of the FD_SETSIZE related problems from
libcurl, we need to provide a function in the multi interface that exports a
set of file descriptors (sockets) that an application should wait for actions
on. It would then not force the app to use select(), but poll() or other
available functions can be used instead.

I have a goal for 7.14 as mentioned in TODO-RELEASE #56, and that requires
that we make a replacement for curl_multi_fdset() first.

So, without thinking too much I thought I'd throw out a first shot at this
replacement function. I call it curl_multi_sock() (for now at least). I'm very
interested in feedback. Would this work/be sufficient?

/* typedef our socket type */
#ifdef WIN32
typedef SOCKET curl_socket_t;
#else
typedef int curl_socket_t;
#endif

struct curl_sock {
   curl_socket_t *rsock; /* points to an array of sockets to check for
                            reading */
   int rsock_num; /* number of sockets in the rsock array */

   curl_socket_t *wsock; /* points to an array of sockets to check for
                            writing */
   int wsock_num; /* number of sockets in the wsock array */

   curl_socket_t *esock; /* points to an array of sockets to check for
                            exception */
   int esock_num; /* number of sockets in the esock array */

   int max; /* the highest socket/file descriptor number used by libcurl (and
               thus included in one of these arrays) */
};

CURLMcode curl_multi_sock(CURLM *multi_handle, struct curl_sock *sockets);

-- 
      Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
       Dedicated custom curl help for hire: http://haxx.se/curl.html
Received on 2005-01-31