CURLOPT_FORBID_REUSE.md (1541B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_FORBID_REUSE 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_FRESH_CONNECT (3) 9 - CURLOPT_MAXCONNECTS (3) 10 - CURLOPT_MAXLIFETIME_CONN (3) 11 Protocol: 12 - All 13 Added-in: 7.7 14 --- 15 16 # NAME 17 18 CURLOPT_FORBID_REUSE - make connection get closed at once after use 19 20 # SYNOPSIS 21 22 ~~~c 23 #include <curl/curl.h> 24 25 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FORBID_REUSE, long close); 26 ~~~ 27 28 # DESCRIPTION 29 30 Pass a long. Set *close* to 1 to make libcurl explicitly close the 31 connection when done with the transfer. Normally, libcurl keeps all 32 connections alive when done with one transfer in case a succeeding one follows 33 that can reuse them. This option should be used with caution and only if you 34 understand what it does as it can seriously impact performance. 35 36 Set to 0 to have libcurl keep the connection open for possible later reuse 37 (default behavior). 38 39 # DEFAULT 40 41 0 42 43 # %PROTOCOLS% 44 45 # EXAMPLE 46 47 ~~~c 48 int 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 68 curl_easy_setopt(3) returns a CURLcode indicating success or error. 69 70 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 71 libcurl-errors(3).