CURLOPT_FT...SE_TIMEOUT(3)

πŸ“¦
version 7.81.0 Β· 2 versions
, in ubuntu jammy

✨ 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_OK if FTP is supported πŸ’š
  • Returns CURLE_UNKNOWN_OPTION if not πŸ™ˆ
  • Returns CURLE_BAD_FUNCTION_ARGUMENT if 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