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