curl_multi_get_handles.md (1732B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: curl_multi_get_handles 5 Section: 3 6 Source: libcurl 7 See-also: 8 - curl_multi_add_handle (3) 9 - curl_multi_cleanup (3) 10 - curl_multi_init (3) 11 - curl_multi_remove_handle (3) 12 Protocol: 13 - All 14 Added-in: 8.4.0 15 --- 16 17 # NAME 18 19 curl_multi_get_handles - return all added easy handles 20 21 # SYNOPSIS 22 23 ~~~c 24 #include <curl/curl.h> 25 26 CURL **curl_multi_get_handles(CURLM *multi_handle); 27 ~~~ 28 29 # DESCRIPTION 30 31 Returns an array with pointers to all added easy handles. The end of the list 32 is marked with a NULL pointer. 33 34 Even if there is not a single easy handle added, this still returns an array 35 but with only a single NULL pointer entry. 36 37 The returned array contains all the handles that are present at the time of 38 the call. As soon as a handle has been removed from or a handle has been added 39 to the multi handle after the handle array was returned, the two data points 40 are out of sync. 41 42 The order of the easy handles within the array is not guaranteed. 43 44 The returned array must be freed with a call to curl_free(3) after use. 45 46 # %PROTOCOLS% 47 48 # EXAMPLE 49 50 ~~~c 51 int main(void) 52 { 53 /* init a multi stack */ 54 CURLM *multi = curl_multi_init(); 55 CURL *curl = curl_easy_init(); 56 57 if(curl) { 58 /* add the transfer */ 59 curl_multi_add_handle(multi, curl); 60 61 /* extract all added handles */ 62 CURL **list = curl_multi_get_handles(multi); 63 64 if(list) { 65 int i; 66 /* remove all added handles */ 67 for(i = 0; list[i]; i++) { 68 curl_multi_remove_handle(multi, list[i]); 69 } 70 curl_free(list); 71 } 72 } 73 } 74 ~~~ 75 76 # %AVAILABILITY% 77 78 # RETURN VALUE 79 80 Returns NULL on failure. Otherwise it returns a pointer to an allocated array.