GNURLOPT_ADDRESS_SCOPE(3)

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

✨ GNURLOPT_ADDRESS_SCOPE(3) ✨

okay so quick vibe check: this is a page from the curl_easy_setopt options manual fam β€” yes, the very same curl_easy_setopt universe you already know and love. pull up a chair bestie πŸ’…


πŸŽ€ NAME πŸŽ€

CURLOPT_ADDRESS_SCOPE β€” sets the scope id for IPv6 addresses. no cap, that's literally its whole job πŸ¦‹


🌸 SYNOPSIS 🌸

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ADDRESS_SCOPE, long
scope);

πŸ’– DESCRIPTION πŸ’–

so what you're gonna do is pass a long that specifies the scope id value to use when you're connecting to IPv6 addresses. that's it. that's the whole thing. iconic, minimal, does exactly what it says on the tin ✨


🫢 DEFAULT 🫢

0


🌈 PROTOCOLS 🌈

All of them β€” but only when you're using IPv6, bestie. it's giving "works everywhere, but only in v6 land" πŸ‘‘


🧚 EXAMPLE 🧚

okay here's the whole thing in action, copy-paste ready, you're welcome:

CURL *curl = curl_easy_init();
if(curl) {
  CURLcode ret;
  long my_scope_id;
  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
  my_scope_id = if_nametoindex("eth0");
  curl_easy_setopt(curl, CURLOPT_ADDRESS_SCOPE, my_scope_id);
  ret = curl_easy_perform(curl);
  curl_easy_cleanup(curl);
}

see how if_nametoindex("eth0") just hands you the scope id? slay. we love a clean handoff 🀝


⭐ AVAILABILITY ⭐

Added in 7.19.0 β€” so it's been around, it's not new new, it's been serving looks since forever πŸ’œ


πŸ”₯ RETURN VALUE πŸ”₯

  • CURLE_OK β€” returned if the option is supported πŸ₯³
  • CURLE_UNKNOWN_OPTION β€” returned if it's not supported πŸ™ˆ
  • CURLE_BAD_FUNCTION_ARGUMENT β€” returned if you set it to a negative value 😭
lowkey watch out for that last one β€” negative values are not the move, and this is how it tells you.

πŸ‘‘ SEE ALSO πŸ‘‘


okay that's the whole page, go forth and scope responsibly πŸ’…βœ¨

libcurl 7.37.0 Β· 19 Jun 2014 β€” mwah, that's the tea, dated and versioned and everything, catch you in the next manpage bestie πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from