cURL / Mailing Lists / curl-library / Single Mail


Re: weird timer behavior when re-using existing connection

From: David Lasker <>
Date: Wed, 18 Jun 2008 09:58:07 -0700

I appear to be completely confused about libcurl timeouts; I hope someone
can straighten me out...

I am using libcurl to replace a homegrown Browser implementation. The legacy
code I am replacing supports individual timeouts for connect, write, and
read on the socket used to communicate with the remote web server. I am
trying to replicate these individual timeouts as close as possible, when
using libcurl to do an HTTP POST.

I am using the multi interface with c-ares.

In my libcurl code, I set CURLOPT_CONNECTTIMEOUT to 20 seconds, and
CURLOPT_TIMEOUT to 100 seconds.

I was assuming that CURLOP_TIMEOUT times the entire HTTP transaction, from
DNS lookup through receipt of data from the remote server, and is inclusive

In the calls libcurl makes to my timer callback function, I can see the 20
second connect timeout, but I don't see any timing being done after the
connection is made. Is libcurl making use of CURLOPT_TIMEOUT?

Is there any way to have libcurl enforce a timeout on the total HTTP
transaction (including write to and read from the web server) when using

Thanks for the help!


On Tue, 17 Jun 2008, Daniel Stenberg wrote:
> On Tue, 17 Jun 2008, David Lasker wrote:
> > On the first HTTP POST, all looks good. My timer callback function is
> > 3 times with the following timeouts:
> >
> > 1. 0
> > 2. 5000 (for the DNS lookup, I think)
> > 3. 20000 (for the rest of the HTTP transaction)
> Did you set any special timeout yourself? The 5000 is indeed for the
> resend of the name resolving, but I'm not sure where 20000 would come
> Possibly it is the 5000 times 4 (the default number of tries c-ares does).
Received on 2008-06-18