add curl_easy handles to working curl_multi_handle
I try to implement multi-threaded downloading using CURL library.
I prepare N threads (easy handles that download different ranges) and invoke curl_multi_perform(mu开发者_如何学JAVAltiHandle, &running) after that.
My questions
- how to check if specific thread (that was added to multi-handle) is downloading now? I haven't found any options.
- If specific thread finishes downloading, It HAS to make connection AGAIN and continue downloading of another range. Is it possible to do?
The libcurl multi interface is not threaded. It does parallel transfers in the same thread!
You can add easy handles to the multi handle at any time you like. Just call curl_multi_perform() then and it'll drive all added easy handles. You can also remove handles at any time.
You should use curl_multi_info_read() to figure out which handles that have completed. Until they are completed, you can consider them in use. If you want to put a easy handle back to the multi handle to do another transfer, just remove it from the handle (possibly set new options) and add it again.
See also http://curl.se/libcurl/c/example.html for lots of libcurl examples, including a bunch that uses the multi interface. The general multi interface "tutorial" style docs is here: http://curl.se/libcurl/c/libcurl-multi.html
精彩评论