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