GNURLMOPT_MAXCONNECTS(3)

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

πŸ’… GNURLMOPT_MAXCONNECTS(3) β€” like, the connection-cache-size glow-up ✨

okay bestie, so this one lives in the curl_multi_setopt options corner of the gnurl/curl manual family (that's the manual name btw, in case you were wondering πŸŽ€). It's all about telling libcurl, "girl, this is how many open connections you're allowed to hoard in your cache."


✨ NAME ✨

CURLMOPT_MAXCONNECTS β€” set size of connection cache πŸ—„οΈ


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <gnurl/curl.h>

CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_MAXCONNECTS, long
max);

🌸 DESCRIPTION 🌸

So you pass a long here, and that's your max, periodt. The number you set becomes the maximum amount of simultaneously open connections that libcurl is allowed to keep hanging around in its connection cache after it's done using them. Like, retired connections that already did their job but are still chilling in the group chat. πŸ’…

Now, the default behavior β€” and this is the part that's giving unhinged β€” is that libcurl will enlarge the cache size for each easy handle you add, so it fits 4 times the number of added easy handles. Yeah. It just keeps growing. She's an overachiever. 😭

By setting this option, you can prevent the cache size from growing beyond the limit you set. Boundaries, bestie. We love them. 🫢

When the cache is full, curl closes the oldest one in the cache to keep the number of open connections from increasing. It's giving seniority-based eviction, ngl. πŸ‘‘

Heads up 🚨 this option is for the multi handle's use only. If you're using the easy interface, you should instead use the CURLOPT_MAXCONNECTS(3) option. Don't mix them up, iykyk.

And if what you actually want is to limit the number of active connections (different vibe entirely), go look at CURLMOPT_MAX_TOTAL_CONNECTIONS(3). 🌈


πŸŽ€ DEFAULT πŸŽ€

See DESCRIPTION (yes, it's a vibe check back to the previous section, that's the whole answer πŸ™ˆ)


🧚 PROTOCOLS 🧚

All β€” literally all of them, every single one, no cap ✨


πŸ”₯ EXAMPLE πŸ”₯

CURLM *m = curl_multi_init();
/* only keep 10 connections in the cache */
curl_multi_setopt(m, CURLMOPT_MAXCONNECTS, 10L);

Ten connections. Only ten. She's minimal, she's chic, she's keeping the cache tidy. πŸ“


⭐ AVAILABILITY ⭐

Added in 7.16.3 β€” vintage but iconic πŸ’œ


πŸ‘‘ RETURN VALUE πŸ‘‘

Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. That's it, that's the whole vibe check. πŸ’€


🌈 SEE ALSO 🌈


okay that's the whole page, bestie, you're officially a connection-cache expert now 🧚✨ this little masterpiece comes to you from libcurl 7.37.0, dated 17 Jun 2014 β€” mwah, go slay your multi handle setup πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from