1--- 2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_FTPPORT 5Section: 3 6Source: libcurl 7See-also: 8 - CURLOPT_FTP_USE_EPRT (3) 9 - CURLOPT_FTP_USE_EPSV (3) 10--- 11 12# NAME 13 14CURLOPT_FTPPORT - make FTP transfer active 15 16# SYNOPSIS 17 18~~~c 19#include <curl/curl.h> 20 21CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTPPORT, char *spec); 22~~~ 23 24# DESCRIPTION 25 26Pass a pointer to a null-terminated string as parameter. It specifies that the 27FTP transfer should be made actively and the given string is used to get the 28IP address to use for the FTP PORT instruction. 29 30The PORT instruction tells the remote server to do a TCP connect to our 31specified IP address. The string may be a plain IP address, a hostname, a 32network interface name (under Unix) or just a '-' symbol to let the library 33use your system's default IP address. Default FTP operations are passive, and 34does not use the PORT command. 35 36The address can be followed by a ':' to specify a port, optionally followed by 37a '-' to specify a port range. If the port specified is 0, the operating 38system picks a free port. If a range is provided and all ports in the range 39are not available, libcurl reports CURLE_FTP_PORT_FAILED for the 40handle. Invalid port/range settings are ignored. IPv6 addresses followed by a 41port or port range have to be in brackets. IPv6 addresses without port/range 42specifier can be in brackets. 43 44Examples with specified ports: 45 46~~~c 47 eth0:0 48 192.168.1.2:32000-33000 49 curl.se:32123 50 [::1]:1234-4567 51~~~ 52 53We strongly advise against specifying the address with a name, as it causes 54libcurl to do a blocking name resolve call to retrieve the IP address. That 55name resolve operation does **not** use DNS-over-HTTPS even if 56CURLOPT_DOH_URL(3) is set. 57 58Using anything else than "-" for this option should typically only be done if 59you have special knowledge and confirmation that it works. 60 61You disable PORT again and go back to using the passive version by setting 62this option to NULL. 63 64The application does not have to keep the string around after setting this 65option. 66 67# DEFAULT 68 69NULL 70 71# PROTOCOLS 72 73FTP 74 75# EXAMPLE 76 77~~~c 78int main(void) 79{ 80 CURL *curl = curl_easy_init(); 81 if(curl) { 82 CURLcode res; 83 curl_easy_setopt(curl, CURLOPT_URL, 84 "ftp://example.com/old-server/file.txt"); 85 curl_easy_setopt(curl, CURLOPT_FTPPORT, "-"); 86 res = curl_easy_perform(curl); 87 curl_easy_cleanup(curl); 88 } 89} 90~~~ 91 92# AVAILABILITY 93 94Port range support was added in 7.19.5 95 96# RETURN VALUE 97 98Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or 99CURLE_OUT_OF_MEMORY if there was insufficient heap space. 100