CURLOPT_WS_OPTIONS.md (1704B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_WS_OPTIONS 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_CONNECT_ONLY (3) 9 - curl_ws_recv (3) 10 - curl_ws_send (3) 11 Protocol: 12 - WS 13 Added-in: 7.86.0 14 --- 15 16 # NAME 17 18 CURLOPT_WS_OPTIONS - WebSocket behavior options 19 20 # SYNOPSIS 21 22 ~~~c 23 #include <curl/curl.h> 24 25 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_WS_OPTIONS, long bitmask); 26 ~~~ 27 28 # DESCRIPTION 29 30 Pass a long with a bitmask to tell libcurl about specific WebSocket 31 behaviors. 32 33 To detach a WebSocket connection and use the curl_ws_send(3) and 34 curl_ws_recv(3) functions after the HTTP upgrade procedure, set the 35 CURLOPT_CONNECT_ONLY(3) option to 2L. 36 37 Available bits in the bitmask 38 39 ## CURLWS_RAW_MODE (1) 40 41 Deliver "raw" WebSocket traffic to the CURLOPT_WRITEFUNCTION(3) 42 callback. 43 44 In raw mode, libcurl does not handle pings or any other frame for the 45 application. 46 47 ## CURLWS_NOAUTOPONG (2) 48 49 Disable the automatic reply to PING messages. This means users must 50 send a PONG message with curl_ws_send(3). This feature is added with 51 version 8.14.0. 52 53 # DEFAULT 54 55 0 56 57 # %PROTOCOLS% 58 59 # EXAMPLE 60 61 ~~~c 62 int main(void) 63 { 64 CURL *curl = curl_easy_init(); 65 if(curl) { 66 CURLcode res; 67 curl_easy_setopt(curl, CURLOPT_URL, "ws://example.com/"); 68 /* tell curl we deal with all the WebSocket magic ourselves */ 69 curl_easy_setopt(curl, CURLOPT_WS_OPTIONS, (long)CURLWS_RAW_MODE); 70 res = curl_easy_perform(curl); 71 curl_easy_cleanup(curl); 72 } 73 } 74 ~~~ 75 76 # %AVAILABILITY% 77 78 # RETURN VALUE 79 80 curl_easy_setopt(3) returns a CURLcode indicating success or error. 81 82 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 83 libcurl-errors(3).