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
12Added-in: 7.15.2
13---
14
15# NAME
16
17CURLOPT_LOCALPORTRANGE - number of additional local ports to try
18
19# SYNOPSIS
20
21~~~c
22#include <curl/curl.h>
23
24CURLcode curl_easy_setopt(CURL *handle, CURLOPT_LOCALPORTRANGE,
25                          long range);
26~~~
27
28# DESCRIPTION
29
30Pass a long. The *range* argument is the number of attempts libcurl makes
31to find a working local port number. It starts with the given
32CURLOPT_LOCALPORT(3) and adds one to the number for each retry. Setting
33this option to 1 or below makes libcurl only do one try for the exact port
34number. Port numbers by nature are scarce resources that are busy at times so
35setting this value to something too low might cause unnecessary connection
36setup failures.
37
38# DEFAULT
39
401
41
42# %PROTOCOLS%
43
44# EXAMPLE
45
46~~~c
47int 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
66Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
67