GNURLINFO_PRIMARY_PORT(3)

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

πŸ’– NAME πŸ’–

okay so this page is GNURLINFO_PRIMARY_PORT(3), from the curl_easy_getinfo options crew, and it's literally about CURLINFO_PRIMARY_PORT β€” get the latest destination port number. slay.


✨ SYNOPSIS ✨

#include <gnurl/curl.h>

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

🌸 DESCRIPTION 🌸

Pass a pointer to a long to receive the destination port of the most recent connection done with this curl handle. that's the whole vibe, bestie πŸ’…


πŸ¦‹ PROTOCOLS πŸ¦‹

All β€” every protocol, no cap.


πŸŽ€ EXAMPLE πŸŽ€

CURL *curl = curl_easy_init();
if(curl) {
  CURLcode res;
  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
  res = curl_easy_perform(curl);
  if(res == CURLE_OK) {
    long port;
    res = curl_easy_getinfo(curl, CURLINFO_PRIMARY_PORT, &port);
    if(!res)
      printf("Connected to remote port: %ld\n", port);
  }
  curl_easy_cleanup(curl);
}

🌈 AVAILABILITY 🌈

Added in 7.21.0 ✨


πŸ’œ RETURN VALUE πŸ’œ

Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. fr fr, that's the check.


🫢 SEE ALSO 🫢


okay bye bestie, this was libcurl 7.44.0 from 12 Sep 2015 β€” mwah πŸ’‹πŸ’…

πŸ“¦ where this page comes from