CURLMOPT_NETWORK_CHANGED(3)

πŸ’… CURLMOPT_NETWORK_CHANGED(3) β€” like, the libcurl manual, bestie

okay so this is a page from the Library Functions Manual and it's literally just called CURLMOPT_NETWORK_CHANGED, and it's about telling libcurl "hey girl, the network changed" πŸ¦‹ stay with me, it's actually so good.


✨ NAME ✨

CURLMOPT_NETWORK_CHANGED β€” signal network changed πŸ’«


πŸŽ€ SYNOPSIS πŸŽ€

#include <curl/curl.h>

CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_NETWORK_CHANGED,
                            long value);

πŸ’– DESCRIPTION πŸ’–

So you pass a long in there that's a bitmask, and it tells the multi handle how it should react. Here's the thing though β€” only the values listed below are defined in that mask. Every other bit? Reserved for future extensions, no cap. πŸ™ˆ

Now this is the iconic part: this option can be set at any time and repeatedly. Each call only affects the connections and DNS info that are currently cached. Any connection created, or DNS info added, afterwards gets cached the usual way again. Phrasing it another way (because yes, the manpage says it twice, and honestly? valid): the option is not persisted β€” setting it is basically a "trigger" to clear the caches. 🧚

Also super important: the call affects only the connection and DNS cache of the multi handle itself, and not the ones owned by SHARE handles. Boundaries, bestie. πŸ’…

  • CURLMNWC_CLEAR_ALL β€” Clear everything. Like, everything everything. (Added in 8.20.0) πŸ”₯
  • CURLMNWC_CLEAR_CONNS β€” No longer reuse any existing connection in the multi handle's connection cache. This closes all connections that are not in use. Ongoing transfers continue on the connections they operate on. So nobody gets yanked mid-transfer, we're not monsters. 🫢
  • CURLMNWC_CLEAR_DNS β€” Clear the multi handle's DNS cache. Ongoing transfers keep using their already resolved addresses, but future name resolutions are performed again. Fresh start energy ✨

🌸 DEFAULT 🌸

0, which has no effect. Nothing happens. A whole lot of nothing. πŸ’€


🌈 PROTOCOLS 🌈

This functionality affects all supported protocols. All of them. Every single one. periodt. πŸ‘‘


⭐ EXAMPLE ⭐

int main(void)
{
  CURLM *m = curl_multi_init();
  /* do transfers on the multi handle */
  /* do not reuse existing connections */
  curl_multi_setopt(m, CURLMOPT_NETWORK_CHANGED, CURLMNWC_CLEAR_CONNS);
}

look at her go 😭 doing transfers, then deciding nope, no more reusing connections. main character energy fr fr.


πŸ¦‹ AVAILABILITY πŸ¦‹

Added in curl 8.16.0. If your curl is older than that, this option simply does not exist for you, iykyk. πŸ₯²


πŸ’œ RETURN VALUE πŸ’œ

curl_multi_setopt(3) returns a CURLMcode indicating success or error.

CURLM_OK (0) means everything was OK. Non-zero means an error occurred β€” see libcurl-errors(3). πŸ’€


πŸ“ SEE ALSO πŸ“


k that's the whole page, you ate that 🫢 this was libcurl, dated 2026-10-25, filed under CURLMOPT_NETWORK_CHANGED(3) β€” mwah, go clear some caches bestie πŸ’…πŸŽ€

πŸ“¦ where this page comes from