CURLOPT_FTPPORT(3)
π CURLOPT_FTPPORT β the "make FTP transfer active" page, bestie
okay so this is a libcurl manpage, CURLOPT_FTPPORT(3), and it's literally about flipping your FTP transfer into active mode. sit down, grab a strawberry drink π, and let's get into it.
β¨ NAME β¨
CURLOPT_FTPPORT β make FTP transfer active π«Ά
πΈ SYNOPSIS πΈ
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTPPORT, char *spec);
π¦ DESCRIPTION π¦
So you pass a pointer to a null-terminated string as the parameter. That string is like, the whole vibe of the operation: it says "yes, make this FTP transfer active", and then the string itself is what's used to get the IP address for the FTP PORT instruction. π
The PORT instruction basically tells the remote server "hi bestie, do a TCP connect to this IP address we're specifying." And the string you give can be a bunch of things:
- a plain IP address
- a hostname
- a network interface name (under Unix)
- or just a
-symbol, which lets the library use your system's default IP address
Default FTP operations are passive, and does not use the PORT command. periodt.
The address can be followed by a : to specify a port, optionally followed by a - to specify a port range. If the port specified is 0, the operating system picks a free port. If a range is provided and all the ports in that range are not available, libcurl reports CURLE_FTP_PORT_FAILED for the handle. π Invalid port/range settings are ignored, ngl.
IPv6 addresses followed by a port or port range have to be in brackets. IPv6 addresses without a port/range specifier can be in brackets.
Examples with specified ports β iconic:
eth0:0
192.168.1.2:32000-33000
curl.se:32123
[::1]:1234-4567
π¨ We strongly advise against specifying the address with a name, because it causes libcurl to do a blocking name resolve call to retrieve the IP address. And that name resolve operation does not use DNS-over-HTTPS even if CURLOPT_DOH_URL(3) is set. so likeβ¦ don't do it unless you know what you're doing β
Using anything else than - for this option should typically only be done if you have special knowledge and confirmation that it works. iykyk.
Good news though: the application does not have to keep the string around after setting this option. π
Using this option multiple times makes the last set string override the previous ones. And if you want to disable PORT again and go back to using the passive version, just set this option to NULL. slay.
π DEFAULT π
NULL
π PROTOCOLS π
This functionality affects ftp only π (yeah, just the one)
β EXAMPLE β
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode result;
curl_easy_setopt(curl, CURLOPT_URL,
"ftp://example.com/old-server/file.txt");
curl_easy_setopt(curl, CURLOPT_FTPPORT, "-");
result = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
}
π AVAILABILITY π
Added in curl 7.1 β she's been around a minute π
π₯ RETURN VALUE π₯
curl_easy_setopt(3) returns a CURLcode indicating success or error.
CURLE_OK (0) means everything was OK β main character energy β¨. Non-zero means an error occurred, see libcurl-errors(3).
π§ SEE ALSO π§
and that's the page, bestie π«Ά this was libcurl, dated 2026-10-12 β go forth and configure responsibly ππΈ
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms