GNURLOPT_LOCALPORTRANGE(3)

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

hey bestie πŸ’– welcome to GNURLOPT_LOCALPORTRANGE(3), aka one of the curl_easy_setopt options manual pages. This one is lowkey all about giving libcurl a range of local ports to try, and it’s short but mighty. πŸŽ€

πŸ’– NAME πŸ’–

CURLOPT_LOCALPORTRANGE β€” number of additional local ports to try. periodt. ✨

✨ SYNOPSIS ✨

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_LOCALPORTRANGE,
                          long range);

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so you pass a long, bestie. The range argument is literally the number of attempts libcurl will make to find a working local port number. It starts with the given CURLOPT_LOCALPORT(3) and adds one to the number for each retry. πŸ‘‘

Setting this option to 1 or below will make libcurl do only one try for the exact port number β€” like, no extra chances, just the one vibe check. 😭 Port numbers by nature are scarce resources that will be busy at times, so setting this value to something too low might cause unnecessary connection setup failures. ngl that’s the important warning: too low = possible avoidable fail energy. πŸ’€

πŸŽ€ DEFAULT πŸŽ€

1 β€” that’s the default, bestie. ✨

🌈 PROTOCOLS 🌈

All. every single one. slay. πŸ’…

πŸ“ EXAMPLE πŸ“

CURL *curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/foo.bin");
  curl_easy_setopt(curl, CURLOPT_LOCALPORT, 49152L);
  /* and try 20 more ports following that */
  curl_easy_setopt(curl, CURLOPT_LOCALPORTRANGE, 20L);
  ret = curl_easy_perform(curl);
  curl_easy_cleanup(curl);
}

πŸ’… AVAILABILITY πŸ’…

Added in 7.15.2. iconic old-school libcurl era. 🫢

⭐ RETURN VALUE ⭐

Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. fr fr, that’s the whole return vibe. 🌟

🫢 SEE ALSO 🫢


later, bestie πŸ’– β€” this page comes from libcurl 7.37.0, dated 19 Jun 2014, and it’s the GNURLOPT_LOCALPORTRANGE(3) page. mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from