curl/docs/libcurl/curl_multi_init.md
Daniel Stenberg 85a81d2789
docs/libcurl: expand multi documentation
curl_multi_init - mention the caches held by the handle

curl_multi_cleanup - mention that the socket callback might be invoked
by this function

Closes #15109
2024-10-01 15:17:17 +02:00

1.4 KiB

c SPDX-License-Identifier Title Section Source See-also Protocol Added-in
Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. curl curl_multi_init 3 libcurl
curl_easy_init (3)
curl_global_init (3)
curl_multi_add_handle (3)
curl_multi_cleanup (3)
curl_multi_get_handles (3)
All
7.9.6

NAME

curl_multi_init - create a multi handle

SYNOPSIS

#include <curl/curl.h>

CURLM *curl_multi_init();

DESCRIPTION

This function returns a pointer to a CURLM handle to be used as input to all the other multi-functions, sometimes referred to as a multi handle in some places in the documentation. This init call MUST have a corresponding call to curl_multi_cleanup(3) when the operation is complete.

By default, several caches are stored in and held by the multi handle: DNS cache, connection pool, TLS session ID cache and the TLS CA cert cache. All transfers using the same multi handle share these caches.

%PROTOCOLS%

EXAMPLE

int main(void)
{
  /* init a multi stack */
  CURLM *multi = curl_multi_init();
  CURL *curl = curl_easy_init();
  CURL *curl2 = curl_easy_init();

  /* add individual transfers */
  curl_multi_add_handle(multi, curl);
  curl_multi_add_handle(multi, curl2);
}

%AVAILABILITY%

RETURN VALUE

If this function returns NULL, something went wrong and you cannot use the other curl functions.