cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: CURLOPT_TIMEOUT and CURLOPT_LOW_SPEED_TIME question

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 7 Nov 2007 16:47:17 +0100 (CET)

On Wed, 7 Nov 2007, Dragos MOINESCU wrote:

> When downloading files (small and large) I need libcurl to close connection
> and return some error code each time the transfer is stalled (no bytes
> coming from peer).

No bytes in what amount of time? "stall" is not a defined state in TCP land,
it is whatever you make it up to be...

> The problem is that setting CURLOPT_LOW_SPEED_TIME means that I cannot allow
> extremely low downloaders to grab a file. I need to download even with 1
> byte / 29 seconds.

So why not 1 byte per 3600 seconds instead? Surely that must be stalled in
most situations?

> I know this scenario is kind of weird, but I really have to do this.

It really isn't weird, if you search the mail archives you see people ask
about this all the time.

If the options aren't enough for you, you can craft your own logic with the
progress callback.

> Also, is there any method to curl_easy_cleanup() during connect()?

> Lets say you use CURLOPT_CONNECTTIMEOUT to set 30 seconds time to connect()
> and in the same time you receive a signal to terminate the process. I would
> like to have a nice method of exiting from curl_easy_perform() in the middle
> of connecting process.

Return the proper code from the progress callback and it'll bail out. But
depending on how you built libcurl there will be situations where it blocks
for a while without calling the progress callback and then the only way to
abort that function varies depending on your operating system. On *nix systems
you can abort most stuff with signals.

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2007-11-07