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