1--- 2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_WS_OPTIONS 5Section: 3 6Source: libcurl 7See-also: 8 - CURLOPT_CONNECT_ONLY (3) 9 - curl_ws_recv (3) 10 - curl_ws_send (3) 11--- 12 13# NAME 14 15CURLOPT_WS_OPTIONS - WebSocket behavior options 16 17# SYNOPSIS 18 19~~~c 20#include <curl/curl.h> 21 22CURLcode curl_easy_setopt(CURL *handle, CURLOPT_WS_OPTIONS, long bitmask); 23~~~ 24 25# DESCRIPTION 26 27Pass a long with a bitmask to tell libcurl about specific WebSocket 28behaviors. 29 30To detach a WebSocket connection and use the curl_ws_send(3) and 31curl_ws_recv(3) functions after the HTTP upgrade procedure, set the 32CURLOPT_CONNECT_ONLY(3) option to 2L. 33 34Available bits in the bitmask 35 36## CURLWS_RAW_MODE (1) 37 38Deliver "raw" WebSocket traffic to the CURLOPT_WRITEFUNCTION(3) 39callback. 40 41In raw mode, libcurl does not handle pings or any other frame for the 42application. 43 44# DEFAULT 45 460 47 48# PROTOCOLS 49 50WebSocket 51 52# EXAMPLE 53 54~~~c 55int main(void) 56{ 57 CURL *curl = curl_easy_init(); 58 if(curl) { 59 CURLcode res; 60 curl_easy_setopt(curl, CURLOPT_URL, "ws://example.com/"); 61 /* tell curl we deal with all the WebSocket magic ourselves */ 62 curl_easy_setopt(curl, CURLOPT_WS_OPTIONS, (long)CURLWS_RAW_MODE); 63 res = curl_easy_perform(curl); 64 curl_easy_cleanup(curl); 65 } 66} 67~~~ 68 69# AVAILABILITY 70 71Added in 7.86.0 72 73# RETURN VALUE 74 75Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. 76