1CURLINFO_PRIMARY_PORT(3) curl_easy_getinfo options CURLINFO_PRIMARY_PORT(3)
2
3
4
6 CURLINFO_PRIMARY_PORT - get the latest destination port number
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PRIMARY_PORT, long *portp);
12
14 Pass a pointer to a long to receive the destination port of the most
15 recent connection done with this curl handle.
16
18 All
19
21 CURL *curl = curl_easy_init();
22 if(curl) {
23 CURLcode res;
24 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
25 res = curl_easy_perform(curl);
26 if(res == CURLE_OK) {
27 long port;
28 res = curl_easy_getinfo(curl, CURLINFO_PRIMARY_PORT, &port);
29 if(!res)
30 printf("Connected to remote port: %ld\n", port);
31 }
32 curl_easy_cleanup(curl);
33 }
34
36 Added in 7.21.0
37
39 Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION
40 if not.
41
43 curl_easy_getinfo(3), curl_easy_setopt(3),
44
45
46
47libcurl 7.82.0 November 26, 2021 CURLINFO_PRIMARY_PORT(3)