1CURLOPT_CONNECT_ONLY(3) curl_easy_setopt options CURLOPT_CONNECT_ONLY(3)
2
3
4
6 CURLOPT_CONNECT_ONLY - stop when connected to target server
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CONNECT_ONLY, long only);
12
14 Pass a long. If the parameter equals 1, it tells the library to perform
15 all the required proxy authentication and connection setup, but no data
16 transfer, and then return.
17
18 The option can be used to simply test a connection to a server, but is
19 more useful when used with the CURLINFO_ACTIVESOCKET(3) option to
20 curl_easy_getinfo(3) as the library can set up the connection and then
21 the application can obtain the most recently used socket for special
22 data transfers.
23
24 Transfers marked connect only will not reuse any existing connections
25 and connections marked connect only will not be allowed to get reused.
26
28 0
29
31 HTTP, SMTP, POP3 and IMAP
32
34 CURL *curl = curl_easy_init();
35 if(curl) {
36 CURLcode ret;
37 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
38 curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
39 ret = curl_easy_perform(curl);
40 if(ret == CURLE_OK) {
41 /* only connected! */
42 }
43 }
44
46 Added in 7.15.2
47
49 Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION
50 if not.
51
53 CURLOPT_VERBOSE(3), CURLOPT_HTTPPROXYTUNNEL(3), curl_easy_recv(3),
54 curl_easy_send(3)
55
56
57
58libcurl 7.82.0 November 26, 2021 CURLOPT_CONNECT_ONLY(3)