1curl_multi_add_handle(3) libcurl Manual curl_multi_add_handle(3)
2
3
4
6 curl_multi_add_handle - add an easy handle to a multi session
7
9 #include <curl/curl.h>
10
11 CURLMcode curl_multi_add_handle(CURLM *multi_handle, CURL *easy_handle);
12
14 Adds a standard easy handle to the multi stack. This function call will
15 make this multi_handle control the specified easy_handle.
16
17 While an easy handle is added to a multi stack, you cannot and you must
18 not use curl_easy_perform(3) on that handle. After having removed the
19 easy handle from the multi stack again, it is perfectly fine to use it
20 with the easy interface again.
21
22 If the easy handle is not set to use a shared (CURLOPT_SHARE(3)) or
23 global DNS cache (CURLOPT_DNS_USE_GLOBAL_CACHE(3)), it will be made to
24 use the DNS cache that is shared between all easy handles within the
25 multi handle when curl_multi_add_handle(3) is called.
26
27 When an easy interface is added to a multi handle, it will use a shared
28 connection cache owned by the multi handle. Removing and adding new
29 easy handles will not affect the pool of connections or the ability to
30 do connection re-use.
31
32 If you have CURLMOPT_TIMERFUNCTION(3) set in the multi handle (and you
33 really should if you are working event-based with curl_multi_socket_ac‐
34 tion(3) and friends), that callback will be called from within this
35 function to ask for an updated timer so that your main event loop will
36 get the activity on this handle to get started.
37
38 The easy handle will remain added to the multi handle until you remove
39 it again with curl_multi_remove_handle(3) - even when a transfer with
40 that specific easy handle is completed.
41
42 You should remove the easy handle from the multi stack before you ter‐
43 minate first the easy handle and then the multi handle:
44
45 1 - curl_multi_remove_handle(3)
46
47 2 - curl_easy_cleanup(3)
48
49 3 - curl_multi_cleanup(3)
50
52 /* init a multi stack */
53 multi_handle = curl_multi_init();
54
55 /* add individual transfers */
56 curl_multi_add_handle(multi_handle, http_handle);
57 curl_multi_add_handle(multi_handle, http_handle2);
58
60 ADded in 7.9.6
61
63 CURLMcode type, general libcurl multi interface error code.
64
66 curl_multi_cleanup(3),curl_multi_init(3), curl_multi_setopt(3),
67 curl_multi_socket_action(3)
68
69
70
71libcurl 7.82.0 November 26, 2021 curl_multi_add_handle(3)