curl_multi_init(3)

πŸ’… curl_multi_init β€” create a multi handle πŸ’…

okay so bestie, this is the curl_multi_init(3) page from the Library Functions Manual and it is so much less scary than it sounds, i promise 🫢


✨ NAME ✨

curl_multi_init β€” create a multi handle πŸŽ€

✨ SYNOPSIS ✨

#include <curl/curl.h>

CURLM *curl_multi_init();

✨ DESCRIPTION ✨

okay so this function hands you back a pointer to a CURLM handle, and that handle is what you feed into all the other multi-functions β€” literally all of them. sometimes the docs just call it a "multi handle" in places, iykyk, that's the same thing πŸ’…

no cap, this is important: this init call MUST have a matching call to curl_multi_cleanup(3) when the operation is complete. like, you don't just leave it hanging. that's not the vibe. that's a leak. 😭

by default, the multi handle is out here holding several caches for you β€” main character energy, it's carrying all of this πŸ‘œβœ¨:

  • the DNS cache
  • the connection pool
  • the TLS session ID cache
  • the TLS CA cert cache

and the way that every single transfer using the same multi handle shares these caches?? obsessed. that's the whole point, that's the slay 🌸

🌈 PROTOCOLS 🌈

this functionality affects all supported protocols β€” yeah, all of them, periodt πŸ‘‘

πŸ¦‹ 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);
}

look at her go πŸ˜ŒπŸ’– two easy handles, one multi handle, all the transfers vibing together.

⭐ AVAILABILITY ⭐

added in curl 7.9.6 β€” an icon, a legend, she's been here a minute πŸŽ€

πŸ’œ RETURN VALUE πŸ’œ

if this function returns NULL, bestie... something went wrong, and you legit cannot use the other curl functions. like, dead end. that's the vibe check failing πŸ™ˆ

πŸ”₯ SEE ALSO πŸ”₯


okay that's the whole page bestie, go build something iconic πŸ’…βœ¨

this masterpiece brought to you by libcurl, dated 2026-10-12 β€” curl_multi_init(3), mwah 🫢

πŸ“¦ where this page comes from