GNURLINFO_LOCAL_PORT(3)

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

GNURLINFO_LOCAL_PORT(3) β€” get the latest local port number πŸ’…

okay so bestie, this page is from the curl_easy_getinfo options manual, and it’s here to explain one very specific little info-getter. no cap, it’s giving β€œwhere did my connection come from, locally?” energy. πŸ¦‹


πŸ’– NAME πŸ’–

CURLINFO_LOCAL_PORT - get the latest local port number ✨

✨ SYNOPSIS ✨

#include <gnurl/curl.h>

CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_LOCAL_PORT, long
*portp);

πŸŽ€ DESCRIPTION πŸŽ€

Pass a pointer to a long, bestie, and it will receive the local port number of the most recent connection done with this curl handle. That’s the whole vibe. πŸ’…

🌈 PROTOCOLS 🌈

All. literally all of them, periodt. πŸ‘‘

πŸ“ EXAMPLE πŸ“

{
  CURL *curl;
  CURLcode res;

  curl = curl_easy_init();
  if(curl) {
    curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/");
    res = curl_easy_perform(curl);

    if(CURLE_OK == res) {
      long port;
      res = curl_easy_getinfo(curl, CURLINFO_LOCAL_PORT, &port);

      if(CURLE_OK == res) {
        printf("We used local port: %ld\n", port);
      }
    }
    curl_easy_cleanup(curl);
  }
  return 0;
}

πŸ¦‹ AVAILABILITY πŸ¦‹

Added in 7.21.0 ⭐

🌸 RETURN VALUE 🌸

Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. simple as that. πŸ’–

🫢 SEE ALSO 🫢


✨ this page is from libcurl 7.44.0, dated 12 Sep 2015 β€” mwah, bye bestie πŸ’–

πŸ“¦ where this page comes from