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