---
name: "CURLOPT_WS_OPTIONS"
section: "3"
platform: "macos"
package: "curl"
version: "166.0.0.0.1"
release: "macOS 26.5"
platforms: ["linux", "macos"]
url: "https://new.carta.tech/CURLOPT_WS_OPTIONS"
---

# CURLOPT\_WS\_OPTIONS(3)

WebSocket behavior options

## NAME

CURLOPT\_WS\_OPTIONS - WebSocket behavior options

## SYNOPSIS

```
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_WS_OPTIONS, long bitmask);
```

## DESCRIPTION

Pass a long with a bitmask to tell libcurl about specific WebSocket behaviors.

To detach a WebSocket connection and use the *[curl\_ws\_send(3)](/curl_ws_send/3.md)* and *[curl\_ws\_recv(3)](/curl_ws_recv/3.md)* functions after the HTTP upgrade procedure, set the *[CURLOPT\_CONNECT\_ONLY(3)](/CURLOPT_CONNECT_ONLY/3.md)* option to 2L.

Available bits in the bitmask

- CURLWS\_RAW\_MODE (1)

  Deliver "raw" WebSocket traffic to the *[CURLOPT\_WRITEFUNCTION(3)](/CURLOPT_WRITEFUNCTION/3.md)* callback.

  In raw mode, libcurl does not handle pings or any other frame for the application.

## DEFAULT

0

## PROTOCOLS

WebSocket

## EXAMPLE

```
int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode res;
    curl_easy_setopt(curl, CURLOPT_URL, "ws://example.com/");
    /* tell curl we deal with all the WebSocket magic ourselves */
    curl_easy_setopt(curl, CURLOPT_WS_OPTIONS, (long)CURLWS_RAW_MODE);
    res = curl_easy_perform(curl);
    curl_easy_cleanup(curl);
  }
}
```

## AVAILABILITY

Added in 7.86.0

## RETURN VALUE

Returns CURLE\_OK if the option is supported, and CURLE\_UNKNOWN\_OPTION if not.

## SEE ALSO

[**CURLOPT\_CONNECT\_ONLY**(3)](/CURLOPT_CONNECT_ONLY/3.md), [**curl\_ws\_recv**(3)](/curl_ws_recv/3.md), [**curl\_ws\_send**(3)](/curl_ws_send/3.md)
