CURLOPT_TCP_KEEPALIVE.3 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. .\" generated by cd2nroff 0.1 from CURLOPT_TCP_KEEPALIVE.md
  2. .TH CURLOPT_TCP_KEEPALIVE 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_TCP_KEEPALIVE \- TCP keep\-alive probing
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_KEEPALIVE, long probe);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a long. If set to 1, TCP keepalive probes are used. The delay and
  12. frequency of these probes can be controlled by the
  13. \fICURLOPT_TCP_KEEPIDLE(3)\fP, \fICURLOPT_TCP_KEEPINTVL(3)\fP, and \fICURLOPT_TCP_KEEPCNT(3)\fP
  14. options, provided the operating system supports them. Set to 0 (default behavior)
  15. to disable keepalive probes.
  16. .SH DEFAULT
  17. 0
  18. .SH PROTOCOLS
  19. This functionality affects tcp only
  20. .SH EXAMPLE
  21. .nf
  22. int main(void)
  23. {
  24. CURL *curl = curl_easy_init();
  25. if(curl) {
  26. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  27. /* enable TCP keep-alive for this transfer */
  28. curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);
  29. /* keep-alive idle time to 120 seconds */
  30. curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 120L);
  31. /* interval time between keep-alive probes: 60 seconds */
  32. curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 60L);
  33. /* maximum number of keep-alive probes: 3 */
  34. curl_easy_setopt(curl, CURLOPT_TCP_KEEPCNT, 3L);
  35. curl_easy_perform(curl);
  36. }
  37. }
  38. .fi
  39. .SH AVAILABILITY
  40. Added in curl 7.25.0
  41. .SH RETURN VALUE
  42. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  43. .SH SEE ALSO
  44. .BR CURLOPT_LOW_SPEED_LIMIT (3),
  45. .BR CURLOPT_MAX_RECV_SPEED_LARGE (3),
  46. .BR CURLOPT_TCP_KEEPCNT (3),
  47. .BR CURLOPT_TCP_KEEPIDLE (3),
  48. .BR CURLOPT_TCP_KEEPINTVL (3)