cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: [hiper] it works!

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 4 Aug 2006 15:22:14 +0200 (CEST)

On Fri, 4 Aug 2006, Alexander Lazic wrote:

>> I'm interested in feeedback on the API, on the docs for it (i.e can you
>> read it and understand how to use it and how to write apps for it?) and
>> possibly more example source codes on how to write applicatons with it. It
>> is somewhat more complicated than the "normal" multi interface.
>
> What i have ask me is what is the *better/preferd* way to use the
> timeoutsettings from curl or the time-events from libevent for connection
> and request timeout?!

Allow me to rant a little around this topic of timeouts.

With libevent (and probably other event libs in similar spirit) you can set
timeouts based on each socket you want the lib to supervise and handle. Now
this is of course very useful for most cases and applications, but...

For libcurl it is not very conveniant to pass along timeouts based on
individual sockets to the application layer, mostly because libcurl isn't
single socket-based and I quickly judged that it would turn quite ugly for
libcurl to have to update those timeout values to the application "all the
time", so I ditched that idea and I instead made libcurl offer a single global
timeout for the next timeout action, that you get with curl_multi_timeout().

So, you don't need any per-socket timeout when you use curl_multi_socket(),
but you need a global timeout that should expire after curl_multi_timeout() if
no action has happened.

The timeout you extract with curl_multi_timeout() is actually a fixed time in
the future, not a relative time. You must/should call curl_multi_socket() at
that time (let's call the time EXPIRE). If there's any action before that time
is reached (like at EXPIRE/2), the timeout value needs to be re-extracted
since it may in fact now want to get called in EXPIRE/2 while if you don't do
it you may continue still using the timeout for EXPIRE...

(Yeah, timev.c doesn't do this so I need to fix it to work like this.)

Was this an answer to the question or did I just confuse you even more?

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2006-08-04