CURLOPT_UPKEEP_INTERVAL_MS.3 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. .\" generated by cd2nroff 0.1 from CURLOPT_UPKEEP_INTERVAL_MS.md
  2. .TH CURLOPT_UPKEEP_INTERVAL_MS 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_UPKEEP_INTERVAL_MS \- connection upkeep interval
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_UPKEEP_INTERVAL_MS,
  9. long upkeep_interval_ms);
  10. .fi
  11. .SH DESCRIPTION
  12. Some protocols have "connection upkeep" mechanisms. These mechanisms usually
  13. send some traffic on existing connections in order to keep them alive; this
  14. can prevent connections from being closed due to overzealous firewalls, for
  15. example.
  16. The user needs to explicitly call \fIcurl_easy_upkeep(3)\fP in order to
  17. perform the upkeep work.
  18. Currently the only protocol with a connection upkeep mechanism is HTTP/2: when
  19. the connection upkeep interval is exceeded and \fIcurl_easy_upkeep(3)\fP
  20. is called, an HTTP/2 PING frame is sent on the connection.
  21. .SH DEFAULT
  22. CURL_UPKEEP_INTERVAL_DEFAULT (currently defined as 60000L, which is 60 seconds)
  23. .SH PROTOCOLS
  24. This functionality affects all supported protocols
  25. .SH EXAMPLE
  26. .nf
  27. int main(void)
  28. {
  29. CURL *curl = curl_easy_init();
  30. if(curl) {
  31. /* Make a connection to an HTTP/2 server. */
  32. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  33. /* Set the interval to 30000ms / 30s */
  34. curl_easy_setopt(curl, CURLOPT_UPKEEP_INTERVAL_MS, 30000L);
  35. curl_easy_perform(curl);
  36. /* Perform more work here. */
  37. /* While the connection is being held open, curl_easy_upkeep() can be
  38. called. If curl_easy_upkeep() is called and the time since the last
  39. upkeep exceeds the interval, then an HTTP/2 PING is sent. */
  40. curl_easy_upkeep(curl);
  41. /* Perform more work here. */
  42. /* always cleanup */
  43. curl_easy_cleanup(curl);
  44. }
  45. }
  46. .fi
  47. .SH AVAILABILITY
  48. Added in curl 7.62.0
  49. .SH RETURN VALUE
  50. Returns CURLE_OK
  51. .SH SEE ALSO
  52. .BR CURLOPT_TCP_KEEPALIVE (3)