| 1 |
.\" ************************************************************************** |
| 2 |
.\" * _ _ ____ _ |
| 3 |
.\" * Project ___| | | | _ \| | |
| 4 |
.\" * / __| | | | |_) | | |
| 5 |
.\" * | (__| |_| | _ <| |___ |
| 6 |
.\" * \___|\___/|_| \_\_____| |
| 7 |
.\" * |
| 8 |
.\" * Copyright (C) 2019, Daniel Stenberg, <[email protected]>, 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.haxx.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 |
.\" ************************************************************************** |
| 22 |
.\" |
| 23 |
.TH CURLOPT_MAXAGE_CONN 3 "18 Apr 2019" "libcurl 7.65.0" "curl_easy_setopt options" |
| 24 |
.SH NAME |
| 25 |
CURLOPT_MAXAGE_CONN \- max idle time allowed for reusing a connection |
| 26 |
.SH SYNOPSIS |
| 27 |
#include <curl/curl.h> |
| 28 |
|
| 29 |
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXAGE_CONN, long maxage); |
| 30 |
.SH DESCRIPTION |
| 31 |
Pass a long as parameter containing \fImaxage\fP - the maximum time in seconds |
| 32 |
that you allow an existing connection to have to be considered for reuse for |
| 33 |
this request. |
| 34 |
|
| 35 |
The "connection cache" that holds previously used connections. When a new |
| 36 |
request is to be done, it will consider any connection that matches for |
| 37 |
reuse. The \fICURLOPT_MAXAGE_CONN(3)\fP limit prevents libcurl from trying |
| 38 |
very old connections for reuse, since old connections have a high risk of not |
| 39 |
working and thus trying them is a performance loss and sometimes service loss |
| 40 |
due to the difficulties to figure out the situation. If a connection is found |
| 41 |
in the cache that is older than this set \fImaxage\fP, it will instead be |
| 42 |
closed. |
| 43 |
.SH DEFAULT |
| 44 |
Default maxage is 118 seconds. |
| 45 |
.SH PROTOCOLS |
| 46 |
All |
| 47 |
.SH EXAMPLE |
| 48 |
.nf |
| 49 |
CURL *curl = curl_easy_init(); |
| 50 |
if(curl) { |
| 51 |
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com"); |
| 52 |
|
| 53 |
/* only allow 30 seconds idle time */ |
| 54 |
curl_easy_setopt(curl, CURLOPT_MAXAGE_CONN, 30L); |
| 55 |
|
| 56 |
curl_easy_perform(curl); |
| 57 |
} |
| 58 |
.fi |
| 59 |
.SH AVAILABILITY |
| 60 |
Added in libcurl 7.65.0 |
| 61 |
.SH RETURN VALUE |
| 62 |
Returns CURLE_OK. |
| 63 |
.SH "SEE ALSO" |
| 64 |
.BR CURLOPT_TIMEOUT "(3), " CURLOPT_FORBID_REUSE "(3), " |
| 65 |
.BR CURLOPT_FRESH_CONNECT "(3), " |