1CURLINFO_LOCAL_PORT(3) curl_easy_getinfo options CURLINFO_LOCAL_PORT(3)
2
3
4
6 CURLINFO_LOCAL_PORT - get the latest local port number
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_LOCAL_PORT, long
12 *portp);
13
15 Pass a pointer to a long to receive the local port number of the most
16 recent connection done with this curl handle.
17
19 All
20
22 {
23 CURL *curl;
24 CURLcode res;
25
26 curl = curl_easy_init();
27 if(curl) {
28 curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/");
29 res = curl_easy_perform(curl);
30
31 if(CURLE_OK == res) {
32 long port;
33 res = curl_easy_getinfo(curl, CURLINFO_LOCAL_PORT, &port);
34
35 if(CURLE_OK == res) {
36 printf("We used local port: %ld\n", port);
37 }
38 }
39 curl_easy_cleanup(curl);
40 }
41 return 0;
42 }
43
45 Added in 7.21.0
46
48 Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION
49 if not.
50
52 curl_easy_getinfo(3), curl_easy_setopt(3), CURLINFO_PRIMARY_PORT(3),
53 CURLINFO_LOCAL_IP(3),
54
55
56
57libcurl 7.61.1 March 16, 2017 CURLINFO_LOCAL_PORT(3)