1CURLOPT_FTPPORT(3)                  libcurl                 CURLOPT_FTPPORT(3)
2
3
4

NAME

6       CURLOPT_FTPPORT - make FTP transfer active
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTPPORT, char *spec);
12

DESCRIPTION

14       Pass  a  pointer to a null-terminated string as parameter. It specifies
15       that the FTP transfer will be made actively and the given  string  will
16       be used to get the IP address to use for the FTP PORT instruction.
17
18       The  PORT  instruction tells the remote server to connect to our speci‐
19       fied IP address. The string may be a plain IP address, a host  name,  a
20       network interface name (under Unix) or just a '-' symbol to let the li‐
21       brary use your system's default IP address. Default FTP operations  are
22       passive, and thus will not use PORT.
23
24       The address can be followed by a ':' to specify a port, optionally fol‐
25       lowed by a '-' to specify a port range. If the port specified is 0, the
26       operating  system will pick a free port. If a range is provided and all
27       ports  in  the  range  are   not   available,   libcurl   will   report
28       CURLE_FTP_PORT_FAILED  for  the handle. Invalid port/range settings are
29       ignored. IPv6 addresses followed by a port or port range have to be  in
30       brackets.  IPv6 addresses without port/range specifier can be in brack‐
31       ets.
32
33       Examples with specified ports:
34
35         eth0:0
36         192.168.1.2:32000-33000
37         curl.se:32123
38         [::1]:1234-4567
39
40       We strongly advise against specifying the address with a  name,  as  it
41       causes  libcurl  to  do a blocking name resolve call to retrieve the IP
42       address. That name resolve operation will not use  DNS-over-HTTPS  even
43       if CURLOPT_DOH_URL(3) is set.
44
45       You disable PORT again and go back to using the passive version by set‐
46       ting this option to NULL.
47
48       The application does not have to keep the string around  after  setting
49       this option.
50

DEFAULT

52       NULL
53

PROTOCOLS

55       FTP
56

EXAMPLE

58       CURL *curl = curl_easy_init();
59       if(curl) {
60         curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/old-server/file.txt");
61         curl_easy_setopt(curl, CURLOPT_FTPPORT, "-");
62         ret = curl_easy_perform(curl);
63         curl_easy_cleanup(curl);
64       }
65

AVAILABILITY

67       Port range support was added in 7.19.5
68

RETURN VALUE

70       Returns  CURLE_OK  if  the option is supported, CURLE_UNKNOWN_OPTION if
71       not, or CURLE_OUT_OF_MEMORY if there was insufficient heap space.
72

SEE ALSO

74       CURLOPT_FTP_USE_EPRT(3), CURLOPT_FTP_USE_EPSV(3),
75
76
77
78ibcurl 8.2.1                    April 26, 2023              CURLOPT_FTPPORT(3)
Impressum