cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Questions on using the curl multi interface

From: lali .cpp <lali.cpp_at_gmail.com>
Date: Fri, 3 Sep 2010 11:10:10 +0530

>> I trust you do curl_multi_add_handle() between 4 and 5!
Yes, I do that as well. Thank you for pointing that out.

>>No, don't break out on timeout. If you want all transfers to complete, you
wait until the transfers are done. Either by checking the running_handles
>>integer curl_multi_perform() stores, or by using curl_multi_info_read().
But my application requires that all transfers should occur within a fixed
time period. I don't really care whether they are complete or not, I just
want to breakout after say 100ms irrespective of whether all transfers are
done or still incomplete. In that case, am I doing the right thing or not?

Regards
lali

On 3 September 2010 02:59, Daniel Stenberg <daniel_at_haxx.se> wrote:

> On Thu, 2 Sep 2010, lali .cpp wrote:
>
> 1. Initialize multi handle (curl_multi_init)
>> 2. setopt on multi handle for CURLMOPT_MAXCONNECTS
>> 3. Initialize easy handles (curl_easy_init)
>> 4. Do setopts on easy handles i.e url to fetch, connnection establishment
>> timeout etc.
>>
>
> I trust you do curl_multi_add_handle() between 4 and 5!
>
>
> 5. Do multiperform, wait on select to know that a fd is ready for I/O.
>> perform I/O(using curl multi perform) or break out of loop on select
>> timeout
>>
>
> No, don't break out on timeout. If you want all transfers to complete, you
> wait until the transfers are done. Either by checking the running_handles
> integer curl_multi_perform() stores, or by using curl_multi_info_read().
>
> See for example http://curl.haxx.se/libcurl/c/multi-double.html
>
>
> So following are my questions:-
>> 1) Is this how curl multi interface needs to be used or should the curl
>> easy
>> handles be reinitialized every time i.e instead of step 4 go to step 3?
>>
>
> Options for easy handles remain set so you can re-use them at will without
> having to set the same options again.
>
>
> 2) Can I do the following:- Initialize the easy handle, use it n times in
>> a
>> multihandle as in the above mentioned 7 steps and then after nth time I go
>> to step 3 instead of 4( Also do curl_easy_cleanup before going to step 3)?
>>
>
> Sure. Or you curl_easy_reset() the handle instead of cleanup/init.
>
> --
>
> / daniel.haxx.se
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html
>

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-09-03