xref: /aosp_15_r20/external/curl/docs/libcurl/opts/CURLOPT_FTPPORT.md (revision 6236dae45794135f37c4eb022389c904c8b0090d)
1*6236dae4SAndroid Build Coastguard Worker---
2*6236dae4SAndroid Build Coastguard Workerc: Copyright (C) Daniel Stenberg, <[email protected]>, et al.
3*6236dae4SAndroid Build Coastguard WorkerSPDX-License-Identifier: curl
4*6236dae4SAndroid Build Coastguard WorkerTitle: CURLOPT_FTPPORT
5*6236dae4SAndroid Build Coastguard WorkerSection: 3
6*6236dae4SAndroid Build Coastguard WorkerSource: libcurl
7*6236dae4SAndroid Build Coastguard WorkerProtocol:
8*6236dae4SAndroid Build Coastguard Worker  - FTP
9*6236dae4SAndroid Build Coastguard WorkerSee-also:
10*6236dae4SAndroid Build Coastguard Worker  - CURLOPT_FTP_USE_EPRT (3)
11*6236dae4SAndroid Build Coastguard Worker  - CURLOPT_FTP_USE_EPSV (3)
12*6236dae4SAndroid Build Coastguard WorkerAdded-in: 7.1
13*6236dae4SAndroid Build Coastguard Worker---
14*6236dae4SAndroid Build Coastguard Worker
15*6236dae4SAndroid Build Coastguard Worker# NAME
16*6236dae4SAndroid Build Coastguard Worker
17*6236dae4SAndroid Build Coastguard WorkerCURLOPT_FTPPORT - make FTP transfer active
18*6236dae4SAndroid Build Coastguard Worker
19*6236dae4SAndroid Build Coastguard Worker# SYNOPSIS
20*6236dae4SAndroid Build Coastguard Worker
21*6236dae4SAndroid Build Coastguard Worker~~~c
22*6236dae4SAndroid Build Coastguard Worker#include <curl/curl.h>
23*6236dae4SAndroid Build Coastguard Worker
24*6236dae4SAndroid Build Coastguard WorkerCURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTPPORT, char *spec);
25*6236dae4SAndroid Build Coastguard Worker~~~
26*6236dae4SAndroid Build Coastguard Worker
27*6236dae4SAndroid Build Coastguard Worker# DESCRIPTION
28*6236dae4SAndroid Build Coastguard Worker
29*6236dae4SAndroid Build Coastguard WorkerPass a pointer to a null-terminated string as parameter. It specifies that the
30*6236dae4SAndroid Build Coastguard WorkerFTP transfer should be made actively and the given string is used to get the
31*6236dae4SAndroid Build Coastguard WorkerIP address to use for the FTP PORT instruction.
32*6236dae4SAndroid Build Coastguard Worker
33*6236dae4SAndroid Build Coastguard WorkerThe PORT instruction tells the remote server to do a TCP connect to our
34*6236dae4SAndroid Build Coastguard Workerspecified IP address. The string may be a plain IP address, a hostname, a
35*6236dae4SAndroid Build Coastguard Workernetwork interface name (under Unix) or just a '-' symbol to let the library
36*6236dae4SAndroid Build Coastguard Workeruse your system's default IP address. Default FTP operations are passive, and
37*6236dae4SAndroid Build Coastguard Workerdoes not use the PORT command.
38*6236dae4SAndroid Build Coastguard Worker
39*6236dae4SAndroid Build Coastguard WorkerThe address can be followed by a ':' to specify a port, optionally followed by
40*6236dae4SAndroid Build Coastguard Workera '-' to specify a port range. If the port specified is 0, the operating
41*6236dae4SAndroid Build Coastguard Workersystem picks a free port. If a range is provided and all ports in the range
42*6236dae4SAndroid Build Coastguard Workerare not available, libcurl reports CURLE_FTP_PORT_FAILED for the
43*6236dae4SAndroid Build Coastguard Workerhandle. Invalid port/range settings are ignored. IPv6 addresses followed by a
44*6236dae4SAndroid Build Coastguard Workerport or port range have to be in brackets. IPv6 addresses without port/range
45*6236dae4SAndroid Build Coastguard Workerspecifier can be in brackets.
46*6236dae4SAndroid Build Coastguard Worker
47*6236dae4SAndroid Build Coastguard WorkerExamples with specified ports:
48*6236dae4SAndroid Build Coastguard Worker
49*6236dae4SAndroid Build Coastguard Worker    eth0:0
50*6236dae4SAndroid Build Coastguard Worker    192.168.1.2:32000-33000
51*6236dae4SAndroid Build Coastguard Worker    curl.se:32123
52*6236dae4SAndroid Build Coastguard Worker    [::1]:1234-4567
53*6236dae4SAndroid Build Coastguard Worker
54*6236dae4SAndroid Build Coastguard WorkerWe strongly advise against specifying the address with a name, as it causes
55*6236dae4SAndroid Build Coastguard Workerlibcurl to do a blocking name resolve call to retrieve the IP address. That
56*6236dae4SAndroid Build Coastguard Workername resolve operation does **not** use DNS-over-HTTPS even if
57*6236dae4SAndroid Build Coastguard WorkerCURLOPT_DOH_URL(3) is set.
58*6236dae4SAndroid Build Coastguard Worker
59*6236dae4SAndroid Build Coastguard WorkerUsing anything else than "-" for this option should typically only be done if
60*6236dae4SAndroid Build Coastguard Workeryou have special knowledge and confirmation that it works.
61*6236dae4SAndroid Build Coastguard Worker
62*6236dae4SAndroid Build Coastguard WorkerThe application does not have to keep the string around after setting this
63*6236dae4SAndroid Build Coastguard Workeroption.
64*6236dae4SAndroid Build Coastguard Worker
65*6236dae4SAndroid Build Coastguard WorkerUsing this option multiple times makes the last set string override the
66*6236dae4SAndroid Build Coastguard Workerprevious ones. You disable PORT again and go back to using the passive version
67*6236dae4SAndroid Build Coastguard Workerby setting this option to NULL.
68*6236dae4SAndroid Build Coastguard Worker
69*6236dae4SAndroid Build Coastguard Worker# DEFAULT
70*6236dae4SAndroid Build Coastguard Worker
71*6236dae4SAndroid Build Coastguard WorkerNULL
72*6236dae4SAndroid Build Coastguard Worker
73*6236dae4SAndroid Build Coastguard Worker# %PROTOCOLS%
74*6236dae4SAndroid Build Coastguard Worker
75*6236dae4SAndroid Build Coastguard Worker# EXAMPLE
76*6236dae4SAndroid Build Coastguard Worker
77*6236dae4SAndroid Build Coastguard Worker~~~c
78*6236dae4SAndroid Build Coastguard Workerint main(void)
79*6236dae4SAndroid Build Coastguard Worker{
80*6236dae4SAndroid Build Coastguard Worker  CURL *curl = curl_easy_init();
81*6236dae4SAndroid Build Coastguard Worker  if(curl) {
82*6236dae4SAndroid Build Coastguard Worker    CURLcode res;
83*6236dae4SAndroid Build Coastguard Worker    curl_easy_setopt(curl, CURLOPT_URL,
84*6236dae4SAndroid Build Coastguard Worker                     "ftp://example.com/old-server/file.txt");
85*6236dae4SAndroid Build Coastguard Worker    curl_easy_setopt(curl, CURLOPT_FTPPORT, "-");
86*6236dae4SAndroid Build Coastguard Worker    res = curl_easy_perform(curl);
87*6236dae4SAndroid Build Coastguard Worker    curl_easy_cleanup(curl);
88*6236dae4SAndroid Build Coastguard Worker  }
89*6236dae4SAndroid Build Coastguard Worker}
90*6236dae4SAndroid Build Coastguard Worker~~~
91*6236dae4SAndroid Build Coastguard Worker
92*6236dae4SAndroid Build Coastguard Worker# %AVAILABILITY%
93*6236dae4SAndroid Build Coastguard Worker
94*6236dae4SAndroid Build Coastguard Worker# RETURN VALUE
95*6236dae4SAndroid Build Coastguard Worker
96*6236dae4SAndroid Build Coastguard WorkerReturns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or
97*6236dae4SAndroid Build Coastguard WorkerCURLE_OUT_OF_MEMORY if there was insufficient heap space.
98