1---
2c: Copyright (C) Daniel Stenberg, <daniel.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)
11---
12
13# NAME
14
15CURLOPT_FORBID_REUSE - make connection get closed at once after use
16
17# SYNOPSIS
18
19~~~c
20#include <curl/curl.h>
21
22CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FORBID_REUSE, long close);
23~~~
24
25# DESCRIPTION
26
27Pass a long. Set *close* to 1 to make libcurl explicitly close the
28connection when done with the transfer. Normally, libcurl keeps all
29connections alive when done with one transfer in case a succeeding one follows
30that can reuse them. This option should be used with caution and only if you
31understand what it does as it can seriously impact performance.
32
33Set to 0 to have libcurl keep the connection open for possible later reuse
34(default behavior).
35
36# DEFAULT
37
380
39
40# PROTOCOLS
41
42Most
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_FORBID_REUSE, 1L);
53    curl_easy_perform(curl);
54
55    /* this second transfer may not reuse the same connection */
56    curl_easy_perform(curl);
57
58    curl_easy_cleanup(curl);
59  }
60}
61~~~
62
63# AVAILABILITY
64
65Always
66
67# RETURN VALUE
68
69Returns CURLE_OK
70