8.12.07

Multiple Transfers Using libcurl multi Interface

"The easy interface as described in detail in this document is a synchronous interface that transfers one file at a time and doesn't return until its done. The multi interface on the other hand, allows your program to transfer multiple files in both directions at the same time, without forcing you to use multiple threads. To use this interface, you are better off if you first understand the basics of how to use the easy interface. The multi interface is simply a way to make multiple transfers at the same time, by adding up multiple easy han- dles in to a 'multi stack'. You create the easy handles you want and you set all the options just like you have been told above, and then you create a multi handle with curl_multi_init(3) and add all those easy handles to that multi handle with curl_multi_add_handle(3). When you've added the handles you have for the moment (you can still add new ones at any time), you start the transfers by call curl_multi_perform(3). curl_multi_perform(3) is asynchronous. It will only execute as little as possible and then return back control to your program. It is designed to never block. If it returns CURLM_CALL_MULTI_PERFORM you better call it again soon, as that is a signal that it still has local data to send or remote data to receive. The best usage of this interface"

No comments: