CURLOPT_FT...SE_TIMEOUT(3)
β¨ CURLOPT_FTP_RESPONSE_TIMEOUT β time allowed to wait for FTP response β¨
okay bestie, gather round, because this one is genuinely one of the most underrated little settings in the whole curl_easy_setopt options fam π this is page CURLOPT_FTP_RESPONSE_TIMEOUT(3), and it's about how long your FTP server is allowed to ghost you before libcurl decides the session is, like, officially deceased π
πΈ SYNOPSIS πΈ
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTP_RESPONSE_TIMEOUT,
long timeout);
π DESCRIPTION π
so you pass a long. that's it, that's the vibe π«Ά
what it does is make libcurl set a timeout period β in seconds β on how long the server is allowed to take to send back a response message for a command. if the server takes longer than that, the session gets considered dead. not "slow", not "having a moment", dead π
and here's the juicy part: while libcurl is sitting there waiting for a response, this value overrides CURLOPT_TIMEOUT(3). it just takes over, main character energy π
the docs do recommend that if you're using this in conjunction with CURLOPT_TIMEOUT(3), you set CURLOPT_FTP_RESPONSE_TIMEOUT(3) to a value smaller than CURLOPT_TIMEOUT(3). so like, layer them properly, don't let them fight π
β DEFAULT β
None
π PROTOCOLS π
FTP
π§ EXAMPLE π§
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/slow.txt");
/* wait no more than 23 seconds */
curl_easy_setopt(curl, CURLOPT_FTP_RESPONSE_TIMEOUT, 23L);
ret = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
look at that /* wait no more than 23 seconds */ comment, so real, so honest π
π¦ AVAILABILITY π¦
Added in 7.10.8 β vintage, but still serving π
π₯ RETURN VALUE π₯
- Returns
CURLE_OKif FTP is supported π - Returns
CURLE_UNKNOWN_OPTIONif not π - Returns
CURLE_BAD_FUNCTION_ARGUMENTif it's set to a negative value, or a value that β once converted to milliseconds β is too large π
bestie, fr fr, don't set this to a negative number. it will not slay. it will return CURLE_BAD_FUNCTION_ARGUMENT and you will simply have to deal with that.
π SEE ALSO π
okay that's the whole page, no cap, nothing skipped π this was libcurl 7.81.0, dated November 26, 2021 β and that's the curl_easy_setopt options section signing off. go forth and give your FTP server a reasonable deadline, bestie, it deserves boundaries πβ¨
π¦ where this page comes from
- ubuntu jammy: libcurl4-doc 7.81.0-1 Β· curl
- ubuntu jammy: libcurl4-doc 7.81.0-1ubuntu1.29
- ubuntu jammy: libcurl4-doc 7.81.0-1ubuntu1.30 Β· curl
- Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms