CURLOPT_FRESH_CONNECT.md (1534B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_FRESH_CONNECT 5 Section: 3 6 Source: libcurl 7 Protocol: 8 - All 9 See-also: 10 - CURLOPT_FORBID_REUSE (3) 11 - CURLOPT_MAXAGE_CONN (3) 12 - CURLOPT_MAXLIFETIME_CONN (3) 13 Added-in: 7.7 14 --- 15 16 # NAME 17 18 CURLOPT_FRESH_CONNECT - force a new connection to be used 19 20 # SYNOPSIS 21 22 ~~~c 23 #include <curl/curl.h> 24 25 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FRESH_CONNECT, long fresh); 26 ~~~ 27 28 # DESCRIPTION 29 30 Pass a long. Set to 1 to make the next transfer use a new (fresh) connection 31 by force instead of trying to reuse an existing one. This option should be 32 used with caution and only if you understand what it does as it may impact 33 performance negatively. 34 35 Related functionality is CURLOPT_FORBID_REUSE(3) which makes sure the 36 connection is closed after use so that it cannot be reused. 37 38 Set *fresh* to 0 to have libcurl attempt reusing an existing connection 39 (default behavior). 40 41 # DEFAULT 42 43 0 44 45 # %PROTOCOLS% 46 47 # EXAMPLE 48 49 ~~~c 50 int 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 67 curl_easy_setopt(3) returns a CURLcode indicating success or error. 68 69 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 70 libcurl-errors(3).