1CURLOPT_CONNECT_ONLY(3)             libcurl            CURLOPT_CONNECT_ONLY(3)
2
3
4

NAME

6       CURLOPT_CONNECT_ONLY - stop when connected to target server
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CONNECT_ONLY, long only);
12

DESCRIPTION

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       Since  7.86.0,  this  option can be set to '2' and if HTTP or WebSocket
25       are used, libcurl will do the request and read all response headers be‐
26       fore handing over control to the application.
27
28       Transfers  marked  connect only will not reuse any existing connections
29       and connections marked connect only will not be allowed to get reused.
30
31       If the connect only transfer is done using  the  multi  interface,  the
32       particular  easy  handle  must  remain added to the multi handle for as
33       long as the application wants to use it. Once it has been removed  with
34       curl_multi_remove_handle(3), curl_easy_send(3) and curl_easy_recv(3) do
35       not function.
36

DEFAULT

38       0
39

PROTOCOLS

41       HTTP, SMTP, POP3 and IMAP. For WS and WSS starting in 7.86.0.
42

EXAMPLE

44       CURL *curl = curl_easy_init();
45       if(curl) {
46         CURLcode ret;
47         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
48         curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
49         ret = curl_easy_perform(curl);
50         if(ret == CURLE_OK) {
51           /* only connected! */
52         }
53       }
54

AVAILABILITY

56       Added in 7.15.2
57

RETURN VALUE

59       Returns CURLE_OK if the option is supported,  and  CURLE_UNKNOWN_OPTION
60       if not.
61

SEE ALSO

63       CURLOPT_VERBOSE(3),    CURLOPT_HTTPPROXYTUNNEL(3),   curl_easy_recv(3),
64       curl_easy_send(3)
65
66
67
68ibcurl 8.2.1                    April 26, 2023         CURLOPT_CONNECT_ONLY(3)
Impressum