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