cURL / Mailing Lists / curl-library / Single Mail

curl-library

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

From: Ben Greear <greearb_at_candelatech.com>
Date: Sun, 30 Jan 2005 15:57:27 -0800

Daniel Stenberg wrote:

> 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);

So, I assume that curl will allocate memory for the curl_socket_t* pointers?

If so, you may want two new methods to help keep people from carelessly
leaking memory:

/** Create new curl_sock structure & initialize values. */
struct curl_sock* curl_multi_socket_create();

/** Cleanup all memory associated with 'sockets'. Do not attempt
  * to reference the sockets struct after calling this method.
  */
void curl_multi_socket_destroy(struct curl_sock *sockets);

Ben

-- 
Ben Greear <greearb_at_candelatech.com>
Candela Technologies Inc  http://www.candelatech.com
Received on 2005-01-31