1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_FRESH_CONNECT
5Section: 3
6Source: libcurl
7Protocol:
8  - All
9See-also:
10  - CURLOPT_FORBID_REUSE (3)
11  - CURLOPT_MAXAGE_CONN (3)
12  - CURLOPT_MAXLIFETIME_CONN (3)
13---
14
15# NAME
16
17CURLOPT_FRESH_CONNECT - force a new connection to be used
18
19# SYNOPSIS
20
21~~~c
22#include <curl/curl.h>
23
24CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FRESH_CONNECT, long fresh);
25~~~
26
27# DESCRIPTION
28
29Pass a long. Set to 1 to make the next transfer use a new (fresh) connection
30by force instead of trying to reuse an existing one. This option should be
31used with caution and only if you understand what it does as it may impact
32performance negatively.
33
34Related functionality is CURLOPT_FORBID_REUSE(3) which makes sure the
35connection is closed after use so that it cannot be reused.
36
37Set *fresh* to 0 to have libcurl attempt reusing an existing connection
38(default behavior).
39
40# DEFAULT
41
420
43
44# EXAMPLE
45
46~~~c
47int main(void)
48{
49  CURL *curl = curl_easy_init();
50  if(curl) {
51    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
52    curl_easy_setopt(curl, CURLOPT_FRESH_CONNECT, 1L);
53    /* this transfer must use a new connection, not reuse an existing */
54    curl_easy_perform(curl);
55    curl_easy_cleanup(curl);
56  }
57}
58~~~
59
60# AVAILABILITY
61
62Always
63
64# RETURN VALUE
65
66Returns CURLE_OK
67