xref: /curl/docs/libcurl/curl_multi_init.md (revision 85a81d27)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: curl_multi_init
5Section: 3
6Source: libcurl
7See-also:
8  - curl_easy_init (3)
9  - curl_global_init (3)
10  - curl_multi_add_handle (3)
11  - curl_multi_cleanup (3)
12  - curl_multi_get_handles (3)
13Protocol:
14  - All
15Added-in: 7.9.6
16---
17
18# NAME
19
20curl_multi_init - create a multi handle
21
22# SYNOPSIS
23
24~~~c
25#include <curl/curl.h>
26
27CURLM *curl_multi_init();
28~~~
29
30# DESCRIPTION
31
32This function returns a pointer to a *CURLM* handle to be used as input to
33all the other multi-functions, sometimes referred to as a multi handle in some
34places in the documentation. This init call MUST have a corresponding call to
35curl_multi_cleanup(3) when the operation is complete.
36
37By default, several caches are stored in and held by the multi handle: DNS
38cache, connection pool, TLS session ID cache and the TLS CA cert cache. All
39transfers using the same multi handle share these caches.
40
41# %PROTOCOLS%
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  CURL *curl2 = curl_easy_init();
52
53  /* add individual transfers */
54  curl_multi_add_handle(multi, curl);
55  curl_multi_add_handle(multi, curl2);
56}
57~~~
58
59# %AVAILABILITY%
60
61# RETURN VALUE
62
63If this function returns NULL, something went wrong and you cannot use the
64other curl functions.
65