CURLOPT_FRESH_CONNECT.3 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. .\" generated by cd2nroff 0.1 from CURLOPT_FRESH_CONNECT.md
  2. .TH CURLOPT_FRESH_CONNECT 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_FRESH_CONNECT \- force a new connection to be used
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FRESH_CONNECT, long fresh);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a long. Set to 1 to make the next transfer use a new (fresh) connection
  12. by force instead of trying to reuse an existing one. This option should be
  13. used with caution and only if you understand what it does as it may impact
  14. performance negatively.
  15. Related functionality is \fICURLOPT_FORBID_REUSE(3)\fP which makes sure the
  16. connection is closed after use so that it cannot be reused.
  17. Set \fIfresh\fP to 0 to have libcurl attempt reusing an existing connection
  18. (default behavior).
  19. .SH DEFAULT
  20. 0
  21. .SH PROTOCOLS
  22. This functionality affects all supported protocols
  23. .SH EXAMPLE
  24. .nf
  25. int main(void)
  26. {
  27. CURL *curl = curl_easy_init();
  28. if(curl) {
  29. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
  30. curl_easy_setopt(curl, CURLOPT_FRESH_CONNECT, 1L);
  31. /* this transfer must use a new connection, not reuse an existing */
  32. curl_easy_perform(curl);
  33. curl_easy_cleanup(curl);
  34. }
  35. }
  36. .fi
  37. .SH AVAILABILITY
  38. Added in curl 7.7
  39. .SH RETURN VALUE
  40. Returns CURLE_OK
  41. .SH SEE ALSO
  42. .BR CURLOPT_FORBID_REUSE (3),
  43. .BR CURLOPT_MAXAGE_CONN (3),
  44. .BR CURLOPT_MAXLIFETIME_CONN (3)