GNURLOPT_MAXCONNECTS(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

πŸŽ€ GNURLOPT_MAXCONNECTS(3) πŸŽ€

okay so bestie, this page is from the curl_easy_setopt options manual (manual name folded in near the top, as requested πŸ’–), and it's lowkey just about setting the maximum connection cache size. no cap. the way that connection pools have main character energy πŸ’…

✨ NAME ✨

CURLOPT_MAXCONNECTS β€” maximum connection cache size. it's giving β€œhow many persistent connections can we keep cached?” 🫢

🌸 SYNOPSIS 🌸

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXCONNECTS, long amount);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so you pass a long, bestie. the amount you set is literally the maximum number of simultaneously open persistent connections that libcurl may cache in the pool associated with this handle. pool party, but make it connection-cache. 🫢

the default is 5, and ngl there isn't much point in changing this value unless you are perfectly aware of how this works and changes libcurl's behaviour. like, fully clued in. periodt. this concerns connections using any of the protocols that support persistent connections.

when reaching the maximum limit, curl closes the oldest one in the cache to prevent increasing the number of open connections. oldest connection gets the goodbye text 😭

if you already have performed transfers with this curl handle, setting a smaller CURLOPT_MAXCONNECTS(3) than before may cause open connections to get closed unnecessarily. so maybe don't casually shrink it mid-vibe, bestie. πŸ’€

multi-handle plot twist: if you add this easy handle to a multi handle, this setting is not acknowledged, and you must instead use curl_multi_setopt(3) and the CURLMOPT_MAXCONNECTS(3) option. iykyk.

πŸ“ DEFAULT πŸ“

5 fr fr.

🌈 PROTOCOLS 🌈

Most.

🧚 EXAMPLE 🧚

this example is iconic, honestly πŸ”₯

CURL *curl = curl_easy_init();
if(curl) {
  CURLcode ret;
  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
  /* limit the connection cache for this handle to no more than 3 */
  curl_easy_setopt(curl, CURLOPT_MAXCONNECTS, 3L);
  ret = curl_easy_perform(curl);
}

πŸ‘‘ AVAILABILITY πŸ‘‘

Always.

⭐ RETURN VALUE ⭐

Returns CURLE_OK. vibe check passed, bestie.

πŸ’œ SEE ALSO πŸ’œ

okay that's the page, bestie πŸ’– β€” footer tea: source/version libcurl 7.37.0, date 17 Jun 2014, and the page is GNURLOPT_MAXCONNECTS(3). mwah, slay, bye. πŸŽ€

πŸ“¦ where this page comes from