1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_FTP_USE_EPSV
5Section: 3
6Source: libcurl
7Protocol:
8  - FTP
9See-also:
10  - CURLOPT_FTPPORT (3)
11  - CURLOPT_FTP_USE_EPRT (3)
12Added-in: 7.9.2
13---
14
15# NAME
16
17CURLOPT_FTP_USE_EPSV - use EPSV for FTP
18
19# SYNOPSIS
20
21~~~c
22#include <curl/curl.h>
23
24CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTP_USE_EPSV, long epsv);
25~~~
26
27# DESCRIPTION
28
29Pass *epsv* as a long. If the value is 1, it tells curl to use the EPSV
30command when doing passive FTP downloads (which it does by default). Using
31EPSV means that libcurl first attempts to use the EPSV command before using
32PASV. If you pass zero to this option, it does not use EPSV, only plain PASV.
33
34The EPSV command is a slightly newer addition to the FTP protocol than PASV
35and is the preferred command to use since it enables IPv6 to be used. Old FTP
36servers might not support it, which is why libcurl has a fallback mechanism.
37Sometimes that fallback is not enough and then this option might come handy.
38
39If the server is an IPv6 host, this option has no effect.
40
41# DEFAULT
42
431
44
45# %PROTOCOLS%
46
47# EXAMPLE
48
49~~~c
50int 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
72Returns CURLE_OK if FTP is supported, and CURLE_UNKNOWN_OPTION if not.
73