1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_FTP_USE_EPRT
5Section: 3
6Source: libcurl
7Protocol:
8  - FTP
9See-also:
10  - CURLOPT_FTPPORT (3)
11  - CURLOPT_FTP_USE_EPSV (3)
12Added-in: 7.10.5
13---
14
15# NAME
16
17CURLOPT_FTP_USE_EPRT - use EPRT for FTP
18
19# SYNOPSIS
20
21~~~c
22#include <curl/curl.h>
23
24CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTP_USE_EPRT, long enabled);
25~~~
26
27# DESCRIPTION
28
29Pass a long. If the value is 1, it tells curl to use the EPRT command when
30doing active FTP downloads (which is enabled by
31CURLOPT_FTPPORT(3)). Using EPRT means that libcurl first attempts to use
32EPRT before using PORT, but if you pass zero to this option, it avoids using
33EPRT, only plain PORT.
34
35The EPRT command is a slightly newer addition to the FTP protocol than PORT
36and is the preferred command to use since it enables IPv6 to be used. Old FTP
37servers might not support it, which is why libcurl has a fallback mechanism.
38Sometimes that fallback is not enough and then this option might come handy.
39
40If the server is an IPv6 host, this option has no effect as EPRT is necessary
41then.
42
43# DEFAULT
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, "ftp://example.com/file.txt");
56
57    /* contact us back, aka "active" FTP */
58    curl_easy_setopt(curl, CURLOPT_FTPPORT, "-");
59
60    /* FTP the way the neanderthals did it */
61    curl_easy_setopt(curl, CURLOPT_FTP_USE_EPRT, 0L);
62
63    res = curl_easy_perform(curl);
64
65    curl_easy_cleanup(curl);
66  }
67}
68~~~
69
70# %AVAILABILITY%
71
72# RETURN VALUE
73
74Returns CURLE_OK
75