CURLOPT_FTP_USE_EPSV.md (1708B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_FTP_USE_EPSV 5 Section: 3 6 Source: libcurl 7 Protocol: 8 - FTP 9 See-also: 10 - CURLOPT_FTPPORT (3) 11 - CURLOPT_FTP_USE_EPRT (3) 12 Added-in: 7.9.2 13 --- 14 15 # NAME 16 17 CURLOPT_FTP_USE_EPSV - use EPSV for FTP 18 19 # SYNOPSIS 20 21 ~~~c 22 #include <curl/curl.h> 23 24 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTP_USE_EPSV, long epsv); 25 ~~~ 26 27 # DESCRIPTION 28 29 Pass *epsv* as a long. If the value is 1, it tells curl to use the EPSV 30 command when doing passive FTP downloads (which it does by default). Using 31 EPSV means that libcurl first attempts to use the EPSV command before using 32 PASV. If you pass zero to this option, it does not use EPSV, only plain PASV. 33 34 The EPSV command is a slightly newer addition to the FTP protocol than PASV 35 and is the preferred command to use since it enables IPv6 to be used. Old FTP 36 servers might not support it, which is why libcurl has a fallback mechanism. 37 Sometimes that fallback is not enough and then this option might come handy. 38 39 If the server is an IPv6 host, this option has no effect. 40 41 # DEFAULT 42 43 1 44 45 # %PROTOCOLS% 46 47 # EXAMPLE 48 49 ~~~c 50 int main(void) 51 { 52 CURL *curl = curl_easy_init(); 53 if(curl) { 54 CURLcode res; 55 curl_easy_setopt(curl, CURLOPT_URL, 56 "ftp://example.com/old-server/file.txt"); 57 58 /* let's shut off this modern feature */ 59 curl_easy_setopt(curl, CURLOPT_FTP_USE_EPSV, 0L); 60 61 res = curl_easy_perform(curl); 62 63 curl_easy_cleanup(curl); 64 } 65 } 66 ~~~ 67 68 # %AVAILABILITY% 69 70 # RETURN VALUE 71 72 curl_easy_setopt(3) returns a CURLcode indicating success or error. 73 74 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 75 libcurl-errors(3).