cURL / Mailing Lists / curl-library / Single Mail


Re: Timeout in multi-threaded program

From: Daniel Stenberg <>
Date: Fri, 23 Nov 2001 10:00:59 +0100 (MET)

On Thu, 22 Nov 2001 wrote:

> From a library user point of view (read I do not intend to modify the
> code of libcurl), is there an alternative to using
> CURLOPT_TIMEOUT/CURLOPT_CONNECTTIMEOUT to have a timeout on a connection
> request in a multi-threading program ?

Nope. :-(

The reason for this is that we have a synchronous name resolver, and we can't
abort that without using signals (and on win32 we can't abort it at all,

Once we get an asynchronous name resolver, which I hope we get one day, then
those options should work unregarding of libcurl being used in multi-threaded
programs or not.

> My program does an HTTP GET from within a CORBA request, and I would like
> to be able to throw an exception back to the client when I've got a
> timeout.

Since you use a multi-threaded program already, you can use a separate thread
that supervises the timer and that runs libcurl an asynch mode, and if the
timer goes off you return and you let the libcurl thread finish by itself
(and stop it as soon as you can) and ignore the results.

I'm open for all suggestions that offer solutions to this problem.

    Daniel Stenberg -- curl groks URLs --
Received on 2001-11-23