1CURLOPT_PORT(3)                     libcurl                    CURLOPT_PORT(3)
2
3
4

NAME

6       CURLOPT_PORT - remote port number to connect to
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PORT, long number);
12

DESCRIPTION

14       We discourage using this option since its scope is not obvious and hard
15       to predict. Set the preferred port number in the URL instead.
16
17       This option sets number to be the remote port number to connect to, in‐
18       stead  of the one specified in the URL or the default port for the used
19       protocol.
20
21       Usually, you just let the URL decide which port to use but this  allows
22       the application to override that.
23
24       While this option accepts a 'long', a port number is an unsigned 16 bit
25       number and therefore using a port number lower than zero or over  65535
26       will cause a CURLE_BAD_FUNCTION_ARGUMENT error.
27

DEFAULT

29       By default this is 0 which makes it not used. This also makes port num‐
30       ber zero impossible to set with this API.
31

PROTOCOLS

33       Used for all protocols that speak to a port number.
34

EXAMPLE

36       CURL *curl = curl_easy_init();
37       if(curl) {
38         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
39         curl_easy_setopt(curl, CURLOPT_PORT, 8080L);
40         ret = curl_easy_perform(curl);
41         curl_easy_cleanup(curl);
42       }
43

AVAILABILITY

45       Always
46

RETURN VALUE

48       Returns CURLE_OK
49

SEE ALSO

51       CURLOPT_STDERR(3), CURLOPT_DEBUGFUNCTION(3),
52
53
54
55ibcurl 8.2.1                    April 26, 2023                 CURLOPT_PORT(3)
Impressum