jpayne@69: #ifndef CURLINC_WEBSOCKETS_H jpayne@69: #define CURLINC_WEBSOCKETS_H jpayne@69: /*************************************************************************** jpayne@69: * _ _ ____ _ jpayne@69: * Project ___| | | | _ \| | jpayne@69: * / __| | | | |_) | | jpayne@69: * | (__| |_| | _ <| |___ jpayne@69: * \___|\___/|_| \_\_____| jpayne@69: * jpayne@69: * Copyright (C) 1998 - 2022, Daniel Stenberg, , et al. jpayne@69: * jpayne@69: * This software is licensed as described in the file COPYING, which jpayne@69: * you should have received as part of this distribution. The terms jpayne@69: * are also available at https://curl.se/docs/copyright.html. jpayne@69: * jpayne@69: * You may opt to use, copy, modify, merge, publish, distribute and/or sell jpayne@69: * copies of the Software, and permit persons to whom the Software is jpayne@69: * furnished to do so, under the terms of the COPYING file. jpayne@69: * jpayne@69: * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY jpayne@69: * KIND, either express or implied. jpayne@69: * jpayne@69: * SPDX-License-Identifier: curl jpayne@69: * jpayne@69: ***************************************************************************/ jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: struct curl_ws_frame { jpayne@69: int age; /* zero */ jpayne@69: int flags; /* See the CURLWS_* defines */ jpayne@69: curl_off_t offset; /* the offset of this data into the frame */ jpayne@69: curl_off_t bytesleft; /* number of pending bytes left of the payload */ jpayne@69: }; jpayne@69: jpayne@69: /* flag bits */ jpayne@69: #define CURLWS_TEXT (1<<0) jpayne@69: #define CURLWS_BINARY (1<<1) jpayne@69: #define CURLWS_CONT (1<<2) jpayne@69: #define CURLWS_CLOSE (1<<3) jpayne@69: #define CURLWS_PING (1<<4) jpayne@69: #define CURLWS_OFFSET (1<<5) jpayne@69: jpayne@69: /* jpayne@69: * NAME curl_ws_recv() jpayne@69: * jpayne@69: * DESCRIPTION jpayne@69: * jpayne@69: * Receives data from the websocket connection. Use after successful jpayne@69: * curl_easy_perform() with CURLOPT_CONNECT_ONLY option. jpayne@69: */ jpayne@69: CURL_EXTERN CURLcode curl_ws_recv(CURL *curl, void *buffer, size_t buflen, jpayne@69: size_t *recv, jpayne@69: struct curl_ws_frame **metap); jpayne@69: jpayne@69: /* sendflags for curl_ws_send() */ jpayne@69: #define CURLWS_PONG (1<<6) jpayne@69: jpayne@69: /* jpayne@69: * NAME curl_easy_send() jpayne@69: * jpayne@69: * DESCRIPTION jpayne@69: * jpayne@69: * Sends data over the websocket connection. Use after successful jpayne@69: * curl_easy_perform() with CURLOPT_CONNECT_ONLY option. jpayne@69: */ jpayne@69: CURL_EXTERN CURLcode curl_ws_send(CURL *curl, const void *buffer, jpayne@69: size_t buflen, size_t *sent, jpayne@69: curl_off_t framesize, jpayne@69: unsigned int sendflags); jpayne@69: jpayne@69: /* bits for the CURLOPT_WS_OPTIONS bitmask: */ jpayne@69: #define CURLWS_RAW_MODE (1<<0) jpayne@69: jpayne@69: CURL_EXTERN struct curl_ws_frame *curl_ws_meta(CURL *curl); jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: #endif /* CURLINC_WEBSOCKETS_H */