GNURLOPT_FTP_RESPONSE_TIMEOUT(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

πŸ’… GNURLOPT_FTP_RESPONSE_TIMEOUT(3) β€” or, "how long do we wait for the FTP server to text back"

okay so this is a page from the curl_easy_setopt options manual, bestie, and it's about one very specific little knob. buckle up πŸŽ€


✨ NAME ✨

CURLOPT_FTP_RESPONSE_TIMEOUT β€” literally just "how long am I allowed to wait for an FTP response before I declare this session deceased" πŸ’€


✨ SYNOPSIS ✨

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTP_RESPONSE_TIMEOUT,
long timeout);

yes, it takes a long. yes, you pass it to curl_easy_setopt. slay. ✨


✨ DESCRIPTION ✨

So you pass a long, right? And what that does is make libcurl set a timeout period β€” in seconds β€” on how much time the server is allowed to take to send back a response message for a command. and if it doesn't text back within that window? the session is considered dead. that's it. that's the whole vibe check πŸ’€

and here's the important part, iykyk: while libcurl is sitting there waiting for a response, this value overrides CURLOPT_TIMEOUT(3). so it's not adding to it, it's straight up taking over. main character energy fr fr πŸ‘‘

the manual also says (and this is genuinely good advice) that if you're using this in conjunction with CURLOPT_TIMEOUT(3), you should set CURLOPT_FTP_RESPONSE_TIMEOUT(3) to a value smaller than CURLOPT_TIMEOUT(3). do with that what you will 🫢


✨ DEFAULT ✨

None β€” no default, no vibes, nothing set unless you set it 🌸


✨ PROTOCOLS ✨

FTP β€” that's it. that's the list. ftp only bestie πŸ¦‹


✨ 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 23L. twenty-three seconds of patience and not one more, we are not waiting around for slow.txt πŸ’…


✨ AVAILABILITY ✨

Added in 7.10.8 β€” she's been iconic for a minute πŸ‘‘


✨ RETURN VALUE ✨

  • Returns CURLE_OK if FTP is supported πŸŽ€
  • Returns CURLE_UNKNOWN_OPTION if not πŸ™ˆ
  • Returns CURLE_BAD_FUNCTION_ARGUMENT if you set it to a negative value, or to a value that β€” when converted to milliseconds β€” is too large. so like, don't do that. seriously. no cap.

✨ SEE ALSO ✨


okay that's the whole page, bestie β€” go forth and set your FTP response timeouts responsibly πŸ§šπŸ’–

psst: the lowkey important takeaway is that this only kicks in while waiting for a response, and it overrides CURLOPT_TIMEOUT(3) during that wait. keep your CURLOPT_FTP_RESPONSE_TIMEOUT(3) smaller than your CURLOPT_TIMEOUT(3) and you're golden ✨

signed off with love from libcurl 7.37.0, dated 19 Jun 2014 β€” a vintage era, honestly, and this page still ate πŸ“

πŸ“¦ where this page comes from