1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_LOCALPORT 5Section: 3 6Source: libcurl 7See-also: 8 - CURLINFO_LOCAL_PORT (3) 9 - CURLOPT_INTERFACE (3) 10 - CURLOPT_LOCALPORTRANGE (3) 11Protocol: 12 - All 13--- 14 15# NAME 16 17CURLOPT_LOCALPORT - local port number to use for socket 18 19# SYNOPSIS 20 21~~~c 22#include <curl/curl.h> 23 24CURLcode curl_easy_setopt(CURL *handle, CURLOPT_LOCALPORT, long port); 25~~~ 26 27# DESCRIPTION 28 29Pass a long. This sets the local port number of the socket used for the 30connection. This can be used in combination with CURLOPT_INTERFACE(3) 31and you are recommended to use CURLOPT_LOCALPORTRANGE(3) as well when 32this option is set. Valid port numbers are 1 - 65535. 33 34# DEFAULT 35 360, disabled - use whatever the system thinks is fine 37 38# EXAMPLE 39 40~~~c 41int main(void) 42{ 43 CURL *curl = curl_easy_init(); 44 if(curl) { 45 CURLcode res; 46 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); 47 curl_easy_setopt(curl, CURLOPT_LOCALPORT, 49152L); 48 /* and try 20 more ports following that */ 49 curl_easy_setopt(curl, CURLOPT_LOCALPORTRANGE, 20L); 50 res = curl_easy_perform(curl); 51 curl_easy_cleanup(curl); 52 } 53} 54~~~ 55 56# AVAILABILITY 57 58Added in 7.15.2 59 60# RETURN VALUE 61 62Returns CURLE_OK 63