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