1--- 2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_PORT 5Section: 3 6Source: libcurl 7See-also: 8 - CURLINFO_PRIMARY_PORT (3) 9 - CURLOPT_STDERR (3) 10 - CURLOPT_URL (3) 11--- 12 13# NAME 14 15CURLOPT_PORT - remote port number to connect to 16 17# SYNOPSIS 18 19~~~c 20#include <curl/curl.h> 21 22CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PORT, long number); 23~~~ 24 25# DESCRIPTION 26 27We discourage using this option since its scope is not obvious and hard to 28predict. Set the preferred port number in the URL instead. 29 30This option sets *number* to be the remote port number to connect to, 31instead of the one specified in the URL or the default port for the used 32protocol. 33 34Usually, you just let the URL decide which port to use but this allows the 35application to override that. 36 37While this option accepts a 'long', a port number is an unsigned 16 bit number 38and therefore using a port number lower than zero or over 65535 causes a 39**CURLE_BAD_FUNCTION_ARGUMENT** error. 40 41# DEFAULT 42 43By default this is 0 which makes it not used. This also makes port number zero 44impossible to set with this API. 45 46# PROTOCOLS 47 48Used for all protocols that speak to a port number. 49 50# EXAMPLE 51 52~~~c 53int main(void) 54{ 55 CURL *curl = curl_easy_init(); 56 if(curl) { 57 CURLcode res; 58 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); 59 curl_easy_setopt(curl, CURLOPT_PORT, 8080L); 60 res = curl_easy_perform(curl); 61 curl_easy_cleanup(curl); 62 } 63} 64~~~ 65 66# AVAILABILITY 67 68Always 69 70# RETURN VALUE 71 72Returns CURLE_OK 73