CURLOPT_LOCALPORTRANGE.md (1573B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_LOCALPORTRANGE 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_INTERFACE (3) 9 - CURLOPT_LOCALPORT (3) 10 Protocol: 11 - All 12 Added-in: 7.15.2 13 --- 14 15 # NAME 16 17 CURLOPT_LOCALPORTRANGE - number of additional local ports to try 18 19 # SYNOPSIS 20 21 ~~~c 22 #include <curl/curl.h> 23 24 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_LOCALPORTRANGE, 25 long range); 26 ~~~ 27 28 # DESCRIPTION 29 30 Pass a long. The *range* argument is the number of attempts libcurl makes 31 to find a working local port number. It starts with the given 32 CURLOPT_LOCALPORT(3) and adds one to the number for each retry. Setting 33 this option to 1 or below makes libcurl only do one try for the exact port 34 number. Port numbers by nature are scarce resources that are busy at times so 35 setting this value to something too low might cause unnecessary connection 36 setup failures. 37 38 # DEFAULT 39 40 1 41 42 # %PROTOCOLS% 43 44 # EXAMPLE 45 46 ~~~c 47 int main(void) 48 { 49 CURL *curl = curl_easy_init(); 50 if(curl) { 51 CURLcode res; 52 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); 53 curl_easy_setopt(curl, CURLOPT_LOCALPORT, 49152L); 54 /* and try 20 more ports following that */ 55 curl_easy_setopt(curl, CURLOPT_LOCALPORTRANGE, 20L); 56 res = curl_easy_perform(curl); 57 curl_easy_cleanup(curl); 58 } 59 } 60 ~~~ 61 62 # %AVAILABILITY% 63 64 # RETURN VALUE 65 66 curl_easy_setopt(3) returns a CURLcode indicating success or error. 67 68 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 69 libcurl-errors(3).