cURL / Mailing Lists / curl-library / Single Mail

curl-library

Setting individual timeouts while using curl multi API.

From: Pranav O. Sharma <pranav_at_yahoo-inc.com>
Date: Tue, 21 Jul 2009 00:28:17 -0700

Hi Everyone,

I'm using curl version 7.19.5 on a FreeBSD 6 system and am using the
curl multi API with socket callbacks set (using the
CURLMOPT_SOCKETFUNCTION option) along with libevent for waiting for
activity on the sockets. I'm using this sample code as my primary
reference: http://curl.haxx.se/lxr/source/docs/examples/hiperfifo.c
<http://curl.haxx.se/lxr/source/docs/examples/hiperfifo.c> . My code is
almost exact as this sample code except for some minor differences.
Everything works fine when the remote server sends a response within a
given time interval. However, I want to set timeouts so that we don't
end up waiting forever. I tried setting timeouts using
CURLOPT_TIMEOUT_MS and CURLOPT_CONNECTTIMEOUT in each easy handle.
However, that didn't work and my application waited forever even when
the server replied *within* the timeout interval. When I set
CURLOPT_NOSIGNAL to 1, things started working for the good case i.e.
when the server replies within the timeout interval. However, when it
doesn't, I see that my application does not timeout but waits until the
server responds, how much every long that is. I tried using a global
timer (using libevent) such that it gets triggered when the timeout
expires but that didn't work either.

 

Can someone please advise how to setup timeouts for the individual easy
handles while using the curl multi interface? Do the CURLOPT_TIMEOUT_MS
and CURLOPT_CONNECTTIMEOUT options not work with the multi interface? If
yes, how does the application know that these timeouts have been
triggered?

 

Thanks,
-Pranav.

 
Received on 2009-07-21