cURL / Mailing Lists / curl-library / Single Mail

curl-library

Best practices for using curl multi api

From: Joshua Litt <jalitt_at_gmail.com>
Date: Tue, 20 Mar 2012 13:27:32 -0700

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
Received on 2012-03-20