Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
websocket.h File Reference

Websocket API. More...

#include <kernel.h>
#include <net/net_ip.h>
#include <net/http_parser.h>
#include <net/http_client.h>

Go to the source code of this file.

Data Structures

struct  websocket_request
 

Macros

#define WEBSOCKET_FLAG_FINAL   0x00000001
 
#define WEBSOCKET_FLAG_TEXT   0x00000002
 
#define WEBSOCKET_FLAG_BINARY   0x00000004
 
#define WEBSOCKET_FLAG_CLOSE   0x00000008
 
#define WEBSOCKET_FLAG_PING   0x00000010
 
#define WEBSOCKET_FLAG_PONG   0x00000020
 

Typedefs

typedef int(* websocket_connect_cb_t) (int ws_sock, struct http_request *req, void *user_data)
 Callback called after Websocket connection is established. More...
 

Enumerations

enum  websocket_opcode {
  WEBSOCKET_OPCODE_CONTINUE = 0x00 , WEBSOCKET_OPCODE_DATA_TEXT = 0x01 , WEBSOCKET_OPCODE_DATA_BINARY = 0x02 , WEBSOCKET_OPCODE_CLOSE = 0x08 ,
  WEBSOCKET_OPCODE_PING = 0x09 , WEBSOCKET_OPCODE_PONG = 0x0A
}
 

Functions

int websocket_connect (int http_sock, struct websocket_request *req, int32_t timeout, void *user_data)
 Connect to a server that provides Websocket service. The callback is called after connection is established. The returned value is a new socket descriptor that can be used to send / receive data using the BSD socket API. More...
 
int websocket_send_msg (int ws_sock, const uint8_t *payload, size_t payload_len, enum websocket_opcode opcode, bool mask, bool final, int32_t timeout)
 Send websocket msg to peer. More...
 
int websocket_recv_msg (int ws_sock, uint8_t *buf, size_t buf_len, uint32_t *message_type, uint64_t *remaining, int32_t timeout)
 Receive websocket msg from peer. More...
 
int websocket_disconnect (int ws_sock)
 Close websocket. More...
 
static void websocket_init (void)
 

Detailed Description

Websocket API.

An API for applications to setup websocket connections