curl_easy_upkeep.3 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .\"
  25. .TH curl_easy_upkeep 3 "31 Oct 2018" "libcurl" "libcurl"
  26. .SH NAME
  27. curl_easy_upkeep - Perform any connection upkeep checks.
  28. .SH SYNOPSIS
  29. .nf
  30. #include <curl/curl.h>
  31. CURLcode curl_easy_upkeep(CURL *handle);
  32. .fi
  33. .SH DESCRIPTION
  34. Some protocols have "connection upkeep" mechanisms. These mechanisms usually
  35. send some traffic on existing connections in order to keep them alive; this
  36. can prevent connections from being closed due to overzealous firewalls, for
  37. example.
  38. Currently the only protocol with a connection upkeep mechanism is HTTP/2: when
  39. the connection upkeep interval is exceeded and \fIcurl_easy_upkeep(3)\fP
  40. is called, an HTTP/2 PING frame is sent on the connection.
  41. This function must be explicitly called in order to perform the upkeep work.
  42. The connection upkeep interval is set with
  43. \fICURLOPT_UPKEEP_INTERVAL_MS(3)\fP.
  44. .SH EXAMPLE
  45. .nf
  46. CURL *curl = curl_easy_init();
  47. if(curl) {
  48. /* Make a connection to an HTTP/2 server. */
  49. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  50. /* Set the interval to 30000ms / 30s */
  51. curl_easy_setopt(curl, CURLOPT_UPKEEP_INTERVAL_MS, 30000L);
  52. curl_easy_perform(curl);
  53. /* Perform more work here. */
  54. /* While the connection is being held open, curl_easy_upkeep() can be
  55. called. If curl_easy_upkeep() is called and the time since the last
  56. upkeep exceeds the interval, then an HTTP/2 PING is sent. */
  57. curl_easy_upkeep(curl);
  58. /* Perform more work here. */
  59. /* always cleanup */
  60. curl_easy_cleanup(curl);
  61. }
  62. .fi
  63. .SH AVAILABILITY
  64. Added in 7.62.0.
  65. .SH RETURN VALUE
  66. On success, returns \fBCURLE_OK\fP.
  67. On failure, returns the appropriate error code.
  68. .SH SEE ALSO
  69. .BR CURLOPT_TCP_KEEPALIVE "(3), "
  70. .BR CURLOPT_TCP_KEEPIDLE "(3), "