curl_easy_upkeep.3 1.8 KB

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