GNURLINFO_LOCAL_PORT(3)
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
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2015, 2017, Daniel Stenberg, <daniel@haxx.se>, et al
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms