1CURLINFO_PRIMARY_PORT(3)   curl_easy_getinfo options  CURLINFO_PRIMARY_PORT(3)
2
3
4

NAME

6       CURLINFO_PRIMARY_PORT - get the latest destination port number
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PRIMARY_PORT, long *portp);
12

DESCRIPTION

14       Pass  a  pointer  to a long to receive the destination port of the most
15       recent connection done with this curl handle.
16
17       This is the destination port  of  the  actual  TCP  or  UDP  connection
18       libcurl  used.   If a proxy was used for the most recent transfer, this
19       is the port number of the proxy, if no proxy was used it  is  the  port
20       number of the most recently accessed URL.
21

PROTOCOLS

23       All
24

EXAMPLE

26       CURL *curl = curl_easy_init();
27       if(curl) {
28         CURLcode res;
29         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
30         res = curl_easy_perform(curl);
31         if(res == CURLE_OK) {
32           long port;
33           res = curl_easy_getinfo(curl, CURLINFO_PRIMARY_PORT, &port);
34           if(!res)
35             printf("Connected to remote port: %ld\n", port);
36         }
37         curl_easy_cleanup(curl);
38       }
39

AVAILABILITY

41       Added in 7.21.0
42

RETURN VALUE

44       Returns  CURLE_OK  if the option is supported, and CURLE_UNKNOWN_OPTION
45       if not.
46

SEE ALSO

48       curl_easy_getinfo(3), curl_easy_setopt(3),
49
50
51
52libcurl 8.0.1                  January 02, 2023       CURLINFO_PRIMARY_PORT(3)
Impressum