CURLOPT_WS_OPTIONS.3 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. .\" generated by cd2nroff 0.1 from CURLOPT_WS_OPTIONS.md
  2. .TH CURLOPT_WS_OPTIONS 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_WS_OPTIONS \- WebSocket behavior options
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_WS_OPTIONS, long bitmask);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a long with a bitmask to tell libcurl about specific WebSocket
  12. behaviors.
  13. To detach a WebSocket connection and use the \fIcurl_ws_send(3)\fP and
  14. \fIcurl_ws_recv(3)\fP functions after the HTTP upgrade procedure, set the
  15. \fICURLOPT_CONNECT_ONLY(3)\fP option to 2L.
  16. Available bits in the bitmask
  17. .IP "CURLWS_RAW_MODE (1)"
  18. Deliver "raw" WebSocket traffic to the \fICURLOPT_WRITEFUNCTION(3)\fP
  19. callback.
  20. In raw mode, libcurl does not handle pings or any other frame for the
  21. application.
  22. .SH DEFAULT
  23. 0
  24. .SH PROTOCOLS
  25. This functionality affects ws only
  26. .SH EXAMPLE
  27. .nf
  28. int main(void)
  29. {
  30. CURL *curl = curl_easy_init();
  31. if(curl) {
  32. CURLcode res;
  33. curl_easy_setopt(curl, CURLOPT_URL, "ws://example.com/");
  34. /* tell curl we deal with all the WebSocket magic ourselves */
  35. curl_easy_setopt(curl, CURLOPT_WS_OPTIONS, (long)CURLWS_RAW_MODE);
  36. res = curl_easy_perform(curl);
  37. curl_easy_cleanup(curl);
  38. }
  39. }
  40. .fi
  41. .SH AVAILABILITY
  42. Added in curl 7.86.0
  43. .SH RETURN VALUE
  44. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  45. .SH SEE ALSO
  46. .BR CURLOPT_CONNECT_ONLY (3),
  47. .BR curl_ws_recv (3),
  48. .BR curl_ws_send (3)