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
13---
14
15# NAME
16
17CURLOPT_FORBID_REUSE - make connection get closed at once after use
18
19# SYNOPSIS
20
21~~~c
22#include <curl/curl.h>
23
24CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FORBID_REUSE, long close);
25~~~
26
27# DESCRIPTION
28
29Pass a long. Set *close* to 1 to make libcurl explicitly close the
30connection when done with the transfer. Normally, libcurl keeps all
31connections alive when done with one transfer in case a succeeding one follows
32that can reuse them. This option should be used with caution and only if you
33understand what it does as it can seriously impact performance.
34
35Set to 0 to have libcurl keep the connection open for possible later reuse
36(default behavior).
37
38# DEFAULT
39
400
41
42# EXAMPLE
43
44~~~c
45int main(void)
46{
47  CURL *curl = curl_easy_init();
48  if(curl) {
49    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
50    curl_easy_setopt(curl, CURLOPT_FORBID_REUSE, 1L);
51    curl_easy_perform(curl);
52
53    /* this second transfer may not reuse the same connection */
54    curl_easy_perform(curl);
55
56    curl_easy_cleanup(curl);
57  }
58}
59~~~
60
61# AVAILABILITY
62
63Always
64
65# RETURN VALUE
66
67Returns CURLE_OK
68