1--- 2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_UPKEEP_INTERVAL_MS 5Section: 3 6Source: libcurl 7See-also: 8 - CURLOPT_TCP_KEEPALIVE (3) 9--- 10 11# NAME 12 13CURLOPT_UPKEEP_INTERVAL_MS - connection upkeep interval 14 15# SYNOPSIS 16 17~~~c 18#include <curl/curl.h> 19 20CURLcode curl_easy_setopt(CURL *handle, CURLOPT_UPKEEP_INTERVAL_MS, 21 long upkeep_interval_ms); 22~~~ 23 24# DESCRIPTION 25 26Some protocols have "connection upkeep" mechanisms. These mechanisms usually 27send some traffic on existing connections in order to keep them alive; this 28can prevent connections from being closed due to overzealous firewalls, for 29example. 30 31The user needs to explicitly call curl_easy_upkeep(3) in order to 32perform the upkeep work. 33 34Currently the only protocol with a connection upkeep mechanism is HTTP/2: when 35the connection upkeep interval is exceeded and curl_easy_upkeep(3) 36is called, an HTTP/2 PING frame is sent on the connection. 37 38# DEFAULT 39 40CURL_UPKEEP_INTERVAL_DEFAULT (currently defined as 60000L, which is 60 seconds) 41 42# PROTOCOLS 43 44All 45 46# EXAMPLE 47 48~~~c 49int main(void) 50{ 51 CURL *curl = curl_easy_init(); 52 if(curl) { 53 /* Make a connection to an HTTP/2 server. */ 54 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 55 56 /* Set the interval to 30000ms / 30s */ 57 curl_easy_setopt(curl, CURLOPT_UPKEEP_INTERVAL_MS, 30000L); 58 59 curl_easy_perform(curl); 60 61 /* Perform more work here. */ 62 63 /* While the connection is being held open, curl_easy_upkeep() can be 64 called. If curl_easy_upkeep() is called and the time since the last 65 upkeep exceeds the interval, then an HTTP/2 PING is sent. */ 66 curl_easy_upkeep(curl); 67 68 /* Perform more work here. */ 69 70 /* always cleanup */ 71 curl_easy_cleanup(curl); 72 } 73} 74~~~ 75 76# AVAILABILITY 77 78Added in 7.62.0 79 80# RETURN VALUE 81 82Returns CURLE_OK 83