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
14Added-in: 8.4.0
15---
16
17# NAME
18
19curl_multi_get_handles - return all added easy handles
20
21# SYNOPSIS
22
23~~~c
24#include <curl/curl.h>
25
26CURL **curl_multi_get_handles(CURLM *multi_handle);
27~~~
28
29# DESCRIPTION
30
31Returns an array with pointers to all added easy handles. The end of the list
32is marked with a NULL pointer.
33
34Even if there is not a single easy handle added, this still returns an array
35but with only a single NULL pointer entry.
36
37The returned array contains all the handles that are present at the time of
38the call. As soon as a handle has been removed from or a handle has been added
39to the multi handle after the handle array was returned, the two data points
40are out of sync.
41
42The order of the easy handles within the array is not guaranteed.
43
44The returned array must be freed with a call to curl_free(3) after use.
45
46# %PROTOCOLS%
47
48# EXAMPLE
49
50~~~c
51int 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
80Returns NULL on failure. Otherwise it returns a pointer to an allocated array.
81