1curl_easy_upkeep(3) libcurl Manual curl_easy_upkeep(3)
2
3
4
6 curl_easy_upkeep - Perform any connection upkeep checks.
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_upkeep(CURL *handle);
12
14 Some protocols have "connection upkeep" mechanisms. These mechanisms
15 usually send some traffic on existing connections in order to keep them
16 alive; this can prevent connections from being closed due to overzeal‐
17 ous firewalls, for example.
18
19 Currently the only protocol with a connection upkeep mechanism is
20 HTTP/2: when the connection upkeep interval is exceeded and
21 curl_easy_upkeep(3) is called, an HTTP/2 PING frame is sent on the con‐
22 nection.
23
24 This function must be explicitly called in order to perform the upkeep
25 work. The connection upkeep interval is set with CURLOPT_UPKEEP_INTER‐
26 VAL_MS(3).
27
28
30 Added in 7.62.0.
31
33 On success, returns CURLE_OK.
34
35 On failure, returns the appropriate error code.
36
37
39 CURL *curl = curl_easy_init();
40 if(curl) {
41 /* Make a connection to an HTTP/2 server. */
42 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
43
44 /* Set the interval to 30000ms / 30s */
45 curl_easy_setopt(curl, CURLOPT_UPKEEP_INTERVAL_MS, 30000L);
46
47 curl_easy_perform(curl);
48
49 /* Perform more work here. */
50
51 /* While the connection is being held open, curl_easy_upkeep() can be
52 called. If curl_easy_upkeep() is called and the time since the last
53 upkeep exceeds the interval, then an HTTP/2 PING is sent. */
54 curl_easy_upkeep(curl);
55
56 /* Perform more work here. */
57
58 /* always cleanup */
59 curl_easy_cleanup(curl);
60 }
61
62
63
64
65libcurl 7.79.1 November 05, 2020 curl_easy_upkeep(3)