cURL / Mailing Lists / curl-library / Single Mail


Re: Modification of curl_multi_fdset()

From: Daniel Stenberg <>
Date: Mon, 9 Jun 2008 16:13:47 +0200 (CEST)

On Mon, 9 Jun 2008, Alexey Simak wrote:

> We call curl_multi_fd_set() to fill fd_sets and then pass them to select().
> We need to track errors on sockets so we have to pass the exceptfds argument
> to select also. So curl_multi_fdset() should fill exc_fd_set from my point
> of view.

You should let libcurl set the file descriptors it deems necessary to watch to
catch libcurl-related actions. You, as an app and user of libcurl, don't need
to worry about what of the fields it thinks are interesting.

The whole point of curl_multi_fdset() is to abstract away that knowledge from
the application.

If you need or want control of specific sockets, curl_multi_socket() might be
the better API for you!

> BTW: why this argument is defined in curl_multi_fdset?

Because if we ever come up with a case where libcurl actually would want to
know and use the exception thing we can make it use it immediately without
breaking the existing ABI or introducing anything new. The three are all used
to select() so it made sense to me to pass all three to curl_multi_fdset()

> With new version of curl_multi_fd_set() we can use the next scenario:
> int max_fd = -1;
> curl_multi_fdset( handle, NULL, write_fd_set, NULL, &max_fd);
> if ( max_fd != -1 ) {
> // some of socket was added to write_fd_set
> }

No you can't. The code in the patch you submitted still uses the socket from
the read situation and ups the "max socket" number with it so the function can
in fact return something else than -1 for max_fd and still not having set
anything in the write_fd_set.

Received on 2008-06-09