1CURLOPT_WS_OPTIONS(3) curl_easy_setopt options CURLOPT_WS_OPTIONS(3)
2
3
4
6 CURLOPT_WS_OPTIONS - WebSocket behavior options
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_WS_OPTIONS, long bitmask);
12
14 Pass a long with a bitmask to tell libcurl about specific WebSocket be‐
15 haviors.
16
17 To detach a WebSocket connection and use the curl_ws_send(3) and
18 curl_ws_recv(3) functions after the HTTP upgrade procedure, set the
19 CURLOPT_CONNECT_ONLY(3) option to 2L.
20
21 Available bits in the bitmask
22
23 CURLWS_RAW_MODE (1)
24 Deliver "raw" WebSocket traffic to the CURLOPT_WRITEFUNCTION(3)
25 callback.
26
27 In raw mode, libcurl does not handle pings or any other frame
28 for the application.
29
31 0
32
34 WebSocket
35
37 CURL *curl = curl_easy_init();
38 if(curl) {
39 curl_easy_setopt(curl, CURLOPT_URL, "ws://example.com/");
40 /* tell curl we deal with all the WebSocket magic ourselves */
41 curl_easy_setopt(curl, CURLOPT_WS_OPTIONS, (long)CURLWS_RAW_MODE);
42 ret = curl_easy_perform(curl);
43 curl_easy_cleanup(curl);
44 }
45
47 Added in 7.86.0
48
50 Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION
51 if not.
52
54 curl_ws_recv(3), curl_ws_send(3),
55
56
57
58libcurl 8.0.1 February 18, 2023 CURLOPT_WS_OPTIONS(3)