---
name: "CURLOPT_WS_OPTIONS"
section: "3"
platform: "linux"
package: "curl"
version: "8.23.0-1"
release: "Arch Linux 2026-11-01"
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. Read "raw" WebSocket traffic from the *[CURLOPT\_READFUNCTION(3)](/CURLOPT_READFUNCTION/3.md)* callback.

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

- CURLWS\_NOAUTOPONG (2)

  Disable the automatic reply to PING messages. This means users must send a PONG message with *[curl\_ws\_send(3)](/curl_ws_send/3.md)*. This feature is added with version 8.14.0.

## DEFAULT

0

## PROTOCOLS

This functionality affects ws only

## EXAMPLE

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

## HISTORY

**CURLWS\_RAW\_MODE** and **CURLWS\_NOAUTOPONG** macros became *long* types in 8.16.0, prior to this version a *long* cast was necessary when passed to *[curl\_easy\_setopt(3)](/curl_easy_setopt/3.md)*.

## AVAILABILITY

Added in curl 7.86.0

## RETURN VALUE

*[curl\_easy\_setopt(3)](/curl_easy_setopt/3.md)* returns a CURLcode indicating success or error.

CURLE\_OK (0) means everything was OK, non-zero means an error occurred, see *[libcurl-errors(3)](/libcurl-errors/3.md)*.

## 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)
