cURL / Mailing Lists / curl-library / Single Mail

curl-library

Questions on using the curl multi interface

From: lali .cpp <lali.cpp_at_gmail.com>
Date: Thu, 2 Sep 2010 16:32:19 +0530

Hi

I am using curl's multi interface in the following way.
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.
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
6. Once out of loop(i.e step 5), remove all the easy handles from curl multi
handle
7. Go to step 4

As you can see, I initialize the curl easy and multi handles only once and
use them in a loop without every initializing them again. Each time I use
setopt for easy handle to fetch a differetnt url.

I don't clean the multi handle as it allows me to reuse established
connections.

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?

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)?

Please point out any issues or problems that could arise with my above
mentioned way to use curl multi interface

Thanks for your patience

Regards
lali

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