CURLOPT_CONNECT_ONLY.3 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. .\" generated by cd2nroff 0.1 from CURLOPT_CONNECT_ONLY.md
  2. .TH CURLOPT_CONNECT_ONLY 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_CONNECT_ONLY \- stop when connected to target server
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CONNECT_ONLY, long only);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a long. If the parameter equals 1, it tells the library to perform all
  12. the required proxy authentication and connection setup, but no data transfer,
  13. and then return.
  14. The option can be used to simply test a connection to a server, but is more
  15. useful when used with the \fICURLINFO_ACTIVESOCKET(3)\fP option to
  16. \fIcurl_easy_getinfo(3)\fP as the library can set up the connection and then
  17. the application can obtain the most recently used socket for special data
  18. transfers.
  19. Since 7.86.0, this option can be set to \(aq2\(aq and if HTTP or WebSocket are used,
  20. libcurl performs the request and reads all response headers before handing
  21. over control to the application.
  22. Transfers marked connect only do not reuse any existing connections and
  23. connections marked connect only are not allowed to get reused.
  24. If the connect only transfer is done using the multi interface, the particular
  25. easy handle must remain added to the multi handle for as long as the
  26. application wants to use it. Once it has been removed with
  27. \fIcurl_multi_remove_handle(3)\fP, \fIcurl_easy_send(3)\fP and
  28. \fIcurl_easy_recv(3)\fP do not function.
  29. .SH DEFAULT
  30. 0
  31. .SH PROTOCOLS
  32. This functionality affects all supported protocols
  33. .SH EXAMPLE
  34. .nf
  35. int main(void)
  36. {
  37. CURL *curl = curl_easy_init();
  38. if(curl) {
  39. CURLcode ret;
  40. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
  41. curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
  42. ret = curl_easy_perform(curl);
  43. if(ret == CURLE_OK) {
  44. /* only connected! */
  45. }
  46. }
  47. }
  48. .fi
  49. .SH HISTORY
  50. WS and WSS support added in 7.86.0.
  51. .SH AVAILABILITY
  52. Added in curl 7.15.2
  53. .SH RETURN VALUE
  54. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  55. .SH SEE ALSO
  56. .BR CURLOPT_HTTPPROXYTUNNEL (3),
  57. .BR CURLOPT_VERBOSE (3),
  58. .BR curl_easy_recv (3),
  59. .BR curl_easy_send (3)