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