cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Best practices for using curl multi api

From: Alan Wolfe <alan.wolfe_at_gmail.com>
Date: Tue, 20 Mar 2012 14:20:15 -0700

i never use fd set when using the multi interface (but your mileage may
require variance!)

I just always call multi preform each frame and read the messages to know
when something has finished.

When going this route, the code is more of a "busy wait" loop instead of a
nice "sleep until there is data available" piece of code, so it is less
than optimal, but it is indeed possible and may be good enough for your
needs.

Of course, you may also just want to figure out the source of your problem
so you can use the nicer pattern of the code.

::shrug::

On Tue, Mar 20, 2012 at 1:27 PM, Joshua Litt <jalitt_at_gmail.com> wrote:

> I am responsible for integrating libcurl into a large c++ single threaded
> request handling server. The asynchronous features of the multi interface
> are especially necessary for our situation. We are using libcurl to send
> http requests to an http server in a nonblocking fashion. At first we will
> only have one connection to the server, but multiple connections are
> possible.
>
> While trying to work through the multi examples, I was wondering, how
> necessary are the fdset / select calls?
>
> curl_multi_fdset <http://curl.haxx.se/libcurl/c/curl_multi_fdset.html>(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
>
> rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
>
> When I try to integrate the example code into our codebase, the select
> never succeeds(always returns -1). However, when I simply call
> curl_multi_perform until 'still_running' changes to 0, everything works as
> expected.
>
>
>
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html
>

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