1CURLOPT_LOCALPORT(3) curl_easy_setopt options CURLOPT_LOCALPORT(3)
2
3
4
6 CURLOPT_LOCALPORT - set local port number to use for socket
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_LOCALPORT, long port);
12
14 Pass a long. This sets the local port number of the socket used for the
15 connection. This can be used in combination with CURLOPT_INTERFACE(3)
16 and you are recommended to use CURLOPT_LOCALPORTRANGE(3) as well when
17 this option is set. Valid port numbers are 1 - 65535.
18
20 0, disabled - use whatever the system thinks is fine
21
23 All
24
26 CURL *curl = curl_easy_init();
27 if(curl) {
28 curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/foo.bin");
29 curl_easy_setopt(curl, CURLOPT_LOCALPORT, 49152L);
30 /* and try 20 more ports following that */
31 curl_easy_setopt(curl, CURLOPT_LOCALPORTRANGE, 20L);
32 ret = curl_easy_perform(curl);
33 curl_easy_cleanup(curl);
34 }
35
37 Added in 7.15.2
38
40 Returns CURLE_OK
41
43 CURLOPT_LOCALPORTRANGE(3), CURLOPT_INTERFACE(3),
44
45
46
47libcurl 7.64.0 January 31, 2019 CURLOPT_LOCALPORT(3)