1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_FORBID_REUSE
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_FRESH_CONNECT (3)
9  - CURLOPT_MAXCONNECTS (3)
10  - CURLOPT_MAXLIFETIME_CONN (3)
11Protocol:
12  - All
13Added-in: 7.7
14---
15
16# NAME
17
18CURLOPT_FORBID_REUSE - make connection get closed at once after use
19
20# SYNOPSIS
21
22~~~c
23#include <curl/curl.h>
24
25CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FORBID_REUSE, long close);
26~~~
27
28# DESCRIPTION
29
30Pass a long. Set *close* to 1 to make libcurl explicitly close the
31connection when done with the transfer. Normally, libcurl keeps all
32connections alive when done with one transfer in case a succeeding one follows
33that can reuse them. This option should be used with caution and only if you
34understand what it does as it can seriously impact performance.
35
36Set to 0 to have libcurl keep the connection open for possible later reuse
37(default behavior).
38
39# DEFAULT
40
410
42
43# %PROTOCOLS%
44
45# EXAMPLE
46
47~~~c
48int main(void)
49{
50  CURL *curl = curl_easy_init();
51  if(curl) {
52    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
53    curl_easy_setopt(curl, CURLOPT_FORBID_REUSE, 1L);
54    curl_easy_perform(curl);
55
56    /* this second transfer may not reuse the same connection */
57    curl_easy_perform(curl);
58
59    curl_easy_cleanup(curl);
60  }
61}
62~~~
63
64# %AVAILABILITY%
65
66# RETURN VALUE
67
68Returns CURLE_OK
69