web_socket.h File Reference

WebSocket API (client and server) More...

#include "core/net.h"
#include "core/socket.h"
#include "core/crypto.h"
#include "tls.h"

Go to the source code of this file.

Data Structures

struct  WebSocketAuthContext
 Authentication context. More...
 
struct  WebSocketHandshakeContext
 Handshake context. More...
 
struct  WebSocketFrameContext
 Frame encoding/decoding context. More...
 
struct  WebSocketUtf8Context
 UTF-8 decoding context. More...
 
struct  _WebSocket
 Structure describing a WebSocket. More...
 

Macros

#define WEB_SOCKET_SUPPORT   DISABLED
 
#define WEB_SOCKET_MAX_COUNT   4
 
#define WEB_SOCKET_TLS_SUPPORT   DISABLED
 
#define WEB_SOCKET_BASIC_AUTH_SUPPORT   DISABLED
 
#define WEB_SOCKET_DIGEST_AUTH_SUPPORT   DISABLED
 
#define WEB_SOCKET_MAX_CONN_RETRIES   3
 
#define WEB_SOCKET_BUFFER_SIZE   1024
 
#define WEB_SOCKET_HOST_MAX_LEN   32
 
#define WEB_SOCKET_ORIGIN_MAX_LEN   16
 
#define WEB_SOCKET_SUB_PROTOCOL_MAX_LEN   8
 
#define WEB_SOCKET_URI_MAX_LEN   32
 
#define WEB_SOCKET_QUERY_STRING_MAX_LEN   32
 
#define WEB_SOCKET_REALM_MAX_LEN   32
 
#define WEB_SOCKET_USERNAME_MAX_LEN   16
 
#define WEB_SOCKET_PASSWORD_MAX_LEN   16
 
#define WEB_SOCKET_NONCE_MAX_LEN   32
 
#define WEB_SOCKET_OPAQUE_MAX_LEN   32
 
#define WEB_SOCKET_CNONCE_SIZE   16
 
#define WEB_SOCKET_CLIENT_KEY_SIZE   24
 
#define WEB_SOCKET_SERVER_KEY_SIZE   28
 
#define WebSocket   struct _WebSocket
 

Typedefs

typedef error_t(* WebSocketRandCallback) (uint8_t *data, size_t length)
 Random data generation callback function. More...
 
typedef error_t(* WebSocketTlsInitCallback) (WebSocket *webSocket, TlsContext *tlsContext)
 TLS initialization callback function. More...
 

Enumerations

enum  WebSocketEndpoint { WS_ENDPOINT_CLIENT = 0, WS_ENDPOINT_SERVER = 1 }
 WebSocket endpoint types. More...
 
enum  WebSocketHttpVersion { WS_HTTP_VERSION_0_9 = 0x0009, WS_HTTP_VERSION_1_0 = 0x0100, WS_HTTP_VERSION_1_1 = 0x0101 }
 HTTP version numbers. More...
 
enum  WebSocketAuthMode { WS_AUTH_MODE_NONE = 0x00, WS_AUTH_MODE_BASIC = 0x01, WS_AUTH_MODE_DIGEST = 0x02 }
 Authentication schemes. More...
 
enum  WebSocketState {
  WS_STATE_UNUSED = 0, WS_STATE_CLOSED = 1, WS_STATE_INIT = 2, WS_STATE_CONNECTING = 3,
  WS_STATE_CLIENT_HANDSHAKE = 4, WS_STATE_SERVER_HANDSHAKE = 5, WS_STATE_SERVER_RESP_BODY = 6, WS_STATE_OPEN = 7,
  WS_STATE_CLOSING_TX = 8, WS_STATE_CLOSING_RX = 9, WS_STATE_SHUTDOWN = 10
}
 WebSocket states. More...
 
enum  WebSocketSubState {
  WS_SUB_STATE_INIT = 0, WS_SUB_STATE_HANDSHAKE_LEADING_LINE = 1, WS_SUB_STATE_HANDSHAKE_HEADER_FIELD = 2, WS_SUB_STATE_HANDSHAKE_LWSP = 3,
  WS_SUB_STATE_FRAME_HEADER = 4, WS_SUB_STATE_FRAME_EXT_HEADER = 5, WS_SUB_STATE_FRAME_PAYLOAD = 6
}
 WebSocket sub-states. More...
 
enum  WebSocketFrameType {
  WS_FRAME_TYPE_CONTINUATION = 0x00, WS_FRAME_TYPE_TEXT = 0x01, WS_FRAME_TYPE_BINARY = 0x02, WS_FRAME_TYPE_CLOSE = 0x08,
  WS_FRAME_TYPE_PING = 0x09, WS_FRAME_TYPE_PONG = 0x0A
}
 WebSocket frame types. More...
 
enum  WebSocketStatusCode {
  WS_STATUS_CODE_NORMAL_CLOSURE = 1000, WS_STATUS_CODE_GOING_AWAY = 1001, WS_STATUS_CODE_PROTOCOL_ERROR = 1002, WS_STATUS_CODE_UNSUPPORTED_DATA = 1003,
  WS_STATUS_CODE_NO_STATUS_RCVD = 1005, WS_STATUS_CODE_ABNORMAL_CLOSURE = 1006, WS_STATUS_CODE_INVALID_PAYLOAD_DATA = 1007, WS_STATUS_CODE_POLICY_VIOLATION = 1008,
  WS_STATUS_CODE_MESSAGE_TOO_BIG = 1009, WS_STATUS_CODE_MANDATORY_EXT = 1010, WS_STATUS_CODE_INTERNAL_ERROR = 1011, WS_STATUS_CODE_TLS_HANDSHAKE = 1015
}
 WebSocket status codes. More...
 

Functions

error_t webSocketInit (void)
 WebSocket related initialization. More...
 
error_t webSocketRegisterRandCallback (WebSocketRandCallback callback)
 Register RNG callback function. More...
 
WebSocketwebSocketOpen (void)
 Create a WebSocket. More...
 
WebSocketwebSocketUpgradeSocket (Socket *socket)
 Upgrade a socket to a WebSocket. More...
 
WebSocketwebSocketUpgradeSecureSocket (Socket *socket, TlsContext *tlsContext)
 Upgrade a secure socket to a secure WebSocket. More...
 
error_t webSocketRegisterTlsInitCallback (WebSocket *webSocket, WebSocketTlsInitCallback callback)
 Register TLS initialization callback function. More...
 
error_t webSocketSetTimeout (WebSocket *webSocket, systime_t timeout)
 Set timeout value for blocking operations. More...
 
error_t webSocketSetHost (WebSocket *webSocket, const char_t *host)
 Set the domain name of the server (for virtual hosting) More...
 
error_t webSocketSetOrigin (WebSocket *webSocket, const char_t *origin)
 Set the origin header field. More...
 
error_t webSocketSetSubProtocol (WebSocket *webSocket, const char_t *subProtocol)
 Set the sub-protocol header field. More...
 
error_t webSocketSetAuthInfo (WebSocket *webSocket, const char_t *username, const char_t *password, uint_t allowedAuthModes)
 Set authentication information. More...
 
error_t webSocketBindToInterface (WebSocket *webSocket, NetInterface *interface)
 Bind the WebSocket to a particular network interface. More...
 
error_t webSocketConnect (WebSocket *webSocket, const IpAddr *serverIpAddr, uint16_t serverPort, const char_t *uri)
 Establish a WebSocket connection. More...
 
error_t webSocketSetClientKey (WebSocket *webSocket, const char_t *clientKey)
 Set client's key. More...
 
error_t webSocketParseClientHandshake (WebSocket *webSocket)
 Parse client's handshake. More...
 
error_t webSocketSendServerHandshake (WebSocket *webSocket)
 Send server's handshake. More...
 
error_t webSocketSendErrorResponse (WebSocket *webSocket, uint_t statusCode, const char_t *message)
 Send HTTP error response to the client. More...
 
error_t webSocketSend (WebSocket *webSocket, const void *data, size_t length, WebSocketFrameType type, size_t *written)
 Transmit data over the WebSocket connection. More...
 
error_t webSocketSendEx (WebSocket *webSocket, const void *data, size_t length, WebSocketFrameType type, size_t *written, bool_t firstFrag, bool_t lastFrag)
 Transmit data over the WebSocket connection. More...
 
error_t webSocketReceive (WebSocket *webSocket, void *data, size_t size, WebSocketFrameType *type, size_t *received)
 Receive data from a WebSocket connection. More...
 
error_t webSocketReceiveEx (WebSocket *webSocket, void *data, size_t size, WebSocketFrameType *type, size_t *received, bool_t *firstFrag, bool_t *lastFrag)
 Receive data from a WebSocket connection. More...
 
bool_t webSocketIsRxReady (WebSocket *webSocket)
 Check whether some data is available in the receive buffer. More...
 
error_t webSocketShutdown (WebSocket *webSocket)
 Gracefully close a WebSocket connection. More...
 
void webSocketClose (WebSocket *webSocket)
 Close a WebSocket connection. More...
 

Variables

typedef __packed_struct
 WebSocket frame. More...
 
uint8_t reserved
 
uint8_t fin
 
uint8_t payloadLen
 
uint8_t mask
 
uint8_t extPayloadLen []
 
 WebSocketFrame
 
WebSocketRandCallback webSockRandCallback
 

Detailed Description

WebSocket API (client and server)

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneTCP Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.4

Definition in file web_socket.h.

Macro Definition Documentation

◆ WEB_SOCKET_BASIC_AUTH_SUPPORT

#define WEB_SOCKET_BASIC_AUTH_SUPPORT   DISABLED

Definition at line 61 of file web_socket.h.

◆ WEB_SOCKET_BUFFER_SIZE

#define WEB_SOCKET_BUFFER_SIZE   1024

Definition at line 82 of file web_socket.h.

◆ WEB_SOCKET_CLIENT_KEY_SIZE

#define WEB_SOCKET_CLIENT_KEY_SIZE   24

Definition at line 171 of file web_socket.h.

◆ WEB_SOCKET_CNONCE_SIZE

#define WEB_SOCKET_CNONCE_SIZE   16

Definition at line 159 of file web_socket.h.

◆ WEB_SOCKET_DIGEST_AUTH_SUPPORT

#define WEB_SOCKET_DIGEST_AUTH_SUPPORT   DISABLED

Definition at line 68 of file web_socket.h.

◆ WEB_SOCKET_HOST_MAX_LEN

#define WEB_SOCKET_HOST_MAX_LEN   32

Definition at line 89 of file web_socket.h.

◆ WEB_SOCKET_MAX_CONN_RETRIES

#define WEB_SOCKET_MAX_CONN_RETRIES   3

Definition at line 75 of file web_socket.h.

◆ WEB_SOCKET_MAX_COUNT

#define WEB_SOCKET_MAX_COUNT   4

Definition at line 47 of file web_socket.h.

◆ WEB_SOCKET_NONCE_MAX_LEN

#define WEB_SOCKET_NONCE_MAX_LEN   32

Definition at line 145 of file web_socket.h.

◆ WEB_SOCKET_OPAQUE_MAX_LEN

#define WEB_SOCKET_OPAQUE_MAX_LEN   32

Definition at line 152 of file web_socket.h.

◆ WEB_SOCKET_ORIGIN_MAX_LEN

#define WEB_SOCKET_ORIGIN_MAX_LEN   16

Definition at line 96 of file web_socket.h.

◆ WEB_SOCKET_PASSWORD_MAX_LEN

#define WEB_SOCKET_PASSWORD_MAX_LEN   16

Definition at line 138 of file web_socket.h.

◆ WEB_SOCKET_QUERY_STRING_MAX_LEN

#define WEB_SOCKET_QUERY_STRING_MAX_LEN   32

Definition at line 117 of file web_socket.h.

◆ WEB_SOCKET_REALM_MAX_LEN

#define WEB_SOCKET_REALM_MAX_LEN   32

Definition at line 124 of file web_socket.h.

◆ WEB_SOCKET_SERVER_KEY_SIZE

#define WEB_SOCKET_SERVER_KEY_SIZE   28

Definition at line 173 of file web_socket.h.

◆ WEB_SOCKET_SUB_PROTOCOL_MAX_LEN

#define WEB_SOCKET_SUB_PROTOCOL_MAX_LEN   8

Definition at line 103 of file web_socket.h.

◆ WEB_SOCKET_SUPPORT

#define WEB_SOCKET_SUPPORT   DISABLED

Definition at line 40 of file web_socket.h.

◆ WEB_SOCKET_TLS_SUPPORT

#define WEB_SOCKET_TLS_SUPPORT   DISABLED

Definition at line 54 of file web_socket.h.

◆ WEB_SOCKET_URI_MAX_LEN

#define WEB_SOCKET_URI_MAX_LEN   32

Definition at line 110 of file web_socket.h.

◆ WEB_SOCKET_USERNAME_MAX_LEN

#define WEB_SOCKET_USERNAME_MAX_LEN   16

Definition at line 131 of file web_socket.h.

◆ WebSocket

#define WebSocket   struct _WebSocket

Definition at line 177 of file web_socket.h.

Typedef Documentation

◆ WebSocketRandCallback

typedef error_t(* WebSocketRandCallback) (uint8_t *data, size_t length)

Random data generation callback function.

Definition at line 337 of file web_socket.h.

◆ WebSocketTlsInitCallback

typedef error_t(* WebSocketTlsInitCallback) (WebSocket *webSocket, TlsContext *tlsContext)

TLS initialization callback function.

Definition at line 347 of file web_socket.h.

Enumeration Type Documentation

◆ WebSocketAuthMode

Authentication schemes.

Enumerator
WS_AUTH_MODE_NONE 
WS_AUTH_MODE_BASIC 
WS_AUTH_MODE_DIGEST 

Definition at line 212 of file web_socket.h.

◆ WebSocketEndpoint

WebSocket endpoint types.

Enumerator
WS_ENDPOINT_CLIENT 
WS_ENDPOINT_SERVER 

Definition at line 189 of file web_socket.h.

◆ WebSocketFrameType

WebSocket frame types.

Enumerator
WS_FRAME_TYPE_CONTINUATION 
WS_FRAME_TYPE_TEXT 
WS_FRAME_TYPE_BINARY 
WS_FRAME_TYPE_CLOSE 
WS_FRAME_TYPE_PING 
WS_FRAME_TYPE_PONG 

Definition at line 262 of file web_socket.h.

◆ WebSocketHttpVersion

HTTP version numbers.

Enumerator
WS_HTTP_VERSION_0_9 
WS_HTTP_VERSION_1_0 
WS_HTTP_VERSION_1_1 

Definition at line 200 of file web_socket.h.

◆ WebSocketState

WebSocket states.

Enumerator
WS_STATE_UNUSED 
WS_STATE_CLOSED 
WS_STATE_INIT 
WS_STATE_CONNECTING 
WS_STATE_CLIENT_HANDSHAKE 
WS_STATE_SERVER_HANDSHAKE 
WS_STATE_SERVER_RESP_BODY 
WS_STATE_OPEN 
WS_STATE_CLOSING_TX 
WS_STATE_CLOSING_RX 
WS_STATE_SHUTDOWN 

Definition at line 224 of file web_socket.h.

◆ WebSocketStatusCode

WebSocket status codes.

Enumerator
WS_STATUS_CODE_NORMAL_CLOSURE 
WS_STATUS_CODE_GOING_AWAY 
WS_STATUS_CODE_PROTOCOL_ERROR 
WS_STATUS_CODE_UNSUPPORTED_DATA 
WS_STATUS_CODE_NO_STATUS_RCVD 
WS_STATUS_CODE_ABNORMAL_CLOSURE 
WS_STATUS_CODE_INVALID_PAYLOAD_DATA 
WS_STATUS_CODE_POLICY_VIOLATION 
WS_STATUS_CODE_MESSAGE_TOO_BIG 
WS_STATUS_CODE_MANDATORY_EXT 
WS_STATUS_CODE_INTERNAL_ERROR 
WS_STATUS_CODE_TLS_HANDSHAKE 

Definition at line 277 of file web_socket.h.

◆ WebSocketSubState

WebSocket sub-states.

Enumerator
WS_SUB_STATE_INIT 
WS_SUB_STATE_HANDSHAKE_LEADING_LINE 
WS_SUB_STATE_HANDSHAKE_HEADER_FIELD 
WS_SUB_STATE_HANDSHAKE_LWSP 
WS_SUB_STATE_FRAME_HEADER 
WS_SUB_STATE_FRAME_EXT_HEADER 
WS_SUB_STATE_FRAME_PAYLOAD 

Definition at line 244 of file web_socket.h.

Function Documentation

◆ webSocketBindToInterface()

error_t webSocketBindToInterface ( WebSocket webSocket,
NetInterface interface 
)

Bind the WebSocket to a particular network interface.

Parameters
[in]webSocketHandle to a WebSocket
[in]interfaceNetwork interface to be used
Returns
Error code

Definition at line 398 of file web_socket.c.

◆ webSocketClose()

void webSocketClose ( WebSocket webSocket)

Close a WebSocket connection.

Parameters
[in]webSocketHandle identifying the WebSocket to close

Definition at line 1591 of file web_socket.c.

◆ webSocketConnect()

error_t webSocketConnect ( WebSocket webSocket,
const IpAddr serverIpAddr,
uint16_t  serverPort,
const char_t uri 
)

Establish a WebSocket connection.

Parameters
[in]webSocketHandle to a WebSocket
[in]serverIpAddrIP address of the WebSocket server to connect to
[in]serverPortTCP port number that will be used to establish the connection
[in]uriNULL-terminated string that contains the resource name
Returns
Error code

Definition at line 422 of file web_socket.c.

◆ webSocketInit()

error_t webSocketInit ( void  )

WebSocket related initialization.

Returns
Error code

Definition at line 60 of file web_socket.c.

◆ webSocketIsRxReady()

bool_t webSocketIsRxReady ( WebSocket webSocket)

Check whether some data is available in the receive buffer.

Parameters
[in]webSocketHandle to a WebSocket
Returns
The function returns TRUE if some data is pending and can be read immediately without blocking. Otherwise, FALSE is returned

Definition at line 1446 of file web_socket.c.

◆ webSocketOpen()

WebSocket* webSocketOpen ( void  )

Create a WebSocket.

Returns
Handle referencing the new WebSocket

Definition at line 95 of file web_socket.c.

◆ webSocketParseClientHandshake()

error_t webSocketParseClientHandshake ( WebSocket webSocket)

Parse client's handshake.

Parameters
[in]webSocketHandle that identifies a WebSocket
Returns
Error code

Definition at line 743 of file web_socket.c.

◆ webSocketReceive()

error_t webSocketReceive ( WebSocket webSocket,
void *  data,
size_t  size,
WebSocketFrameType type,
size_t *  received 
)

Receive data from a WebSocket connection.

Parameters
[in]webSocketHandle that identifies a WebSocket
[out]dataBuffer where to store the incoming data
[in]sizeMaximum number of bytes that can be received
[out]typeFrame type
[out]receivedNumber of bytes that have been received
Returns
Error code

Definition at line 1156 of file web_socket.c.

◆ webSocketReceiveEx()

error_t webSocketReceiveEx ( WebSocket webSocket,
void *  data,
size_t  size,
WebSocketFrameType type,
size_t *  received,
bool_t firstFrag,
bool_t lastFrag 
)

Receive data from a WebSocket connection.

Parameters
[in]webSocketHandle that identifies a WebSocket
[out]dataBuffer where to store the incoming data
[in]sizeMaximum number of bytes that can be received
[out]typeFrame type
[out]receivedNumber of bytes that have been received
[out]firstFragFirst fragment of the message
[out]lastFragLast fragment of the message
Returns
Error code

Definition at line 1179 of file web_socket.c.

◆ webSocketRegisterRandCallback()

error_t webSocketRegisterRandCallback ( WebSocketRandCallback  callback)

Register RNG callback function.

Parameters
[in]callbackRNG callback function
Returns
Error code

Definition at line 76 of file web_socket.c.

◆ webSocketRegisterTlsInitCallback()

error_t webSocketRegisterTlsInitCallback ( WebSocket webSocket,
WebSocketTlsInitCallback  callback 
)

Register TLS initialization callback function.

Parameters
[in]webSocketHandle that identifies a WebSocket
[in]callbackTLS initialization callback function
Returns
Error code

Definition at line 233 of file web_socket.c.

◆ webSocketSend()

error_t webSocketSend ( WebSocket webSocket,
const void *  data,
size_t  length,
WebSocketFrameType  type,
size_t *  written 
)

Transmit data over the WebSocket connection.

Parameters
[in]webSocketHandle that identifies a WebSocket
[in]dataPointer to a buffer containing the data to be transmitted
[in]lengthNumber of data bytes to send
[in]typeFrame type
[out]writtenActual number of bytes written (optional parameter)
Returns
Error code

Definition at line 970 of file web_socket.c.

◆ webSocketSendErrorResponse()

error_t webSocketSendErrorResponse ( WebSocket webSocket,
uint_t  statusCode,
const char_t message 
)

Send HTTP error response to the client.

Parameters
[in]webSocketHandle that identifies a WebSocket
[in]statusCodeHTTP status code
[in]messageText message
Returns
Error code

Definition at line 895 of file web_socket.c.

◆ webSocketSendEx()

error_t webSocketSendEx ( WebSocket webSocket,
const void *  data,
size_t  length,
WebSocketFrameType  type,
size_t *  written,
bool_t  firstFrag,
bool_t  lastFrag 
)

Transmit data over the WebSocket connection.

Parameters
[in]webSocketHandle that identifies a WebSocket
[in]dataPointer to a buffer containing the data to be transmitted
[in]lengthNumber of data bytes to send
[in]typeFrame type
[out]writtenActual number of bytes written (optional parameter)
[in]firstFragFirst fragment of the message
[in]lastFragLast fragment of the message

Definition at line 991 of file web_socket.c.

◆ webSocketSendServerHandshake()

error_t webSocketSendServerHandshake ( WebSocket webSocket)

Send server's handshake.

Parameters
[in]webSocketHandle that identifies a WebSocket
Returns
Error code

Definition at line 832 of file web_socket.c.

◆ webSocketSetAuthInfo()

error_t webSocketSetAuthInfo ( WebSocket webSocket,
const char_t username,
const char_t password,
uint_t  allowedAuthModes 
)

Set authentication information.

Parameters
[in]webSocketHandle to a WebSocket
[in]usernameNULL-terminated string containing the user name to be used
[in]passwordNULL-terminated string containing the password to be used
[in]allowedAuthModesLogic OR of allowed HTTP authentication schemes
Returns
Error code

Definition at line 359 of file web_socket.c.

◆ webSocketSetClientKey()

error_t webSocketSetClientKey ( WebSocket webSocket,
const char_t clientKey 
)

Set client's key.

Parameters
[in]webSocketHandle to a WebSocket
[in]clientKeyNULL-terminated string that holds the client's key
Returns
Error code

Definition at line 677 of file web_socket.c.

◆ webSocketSetHost()

error_t webSocketSetHost ( WebSocket webSocket,
const char_t host 
)

Set the domain name of the server (for virtual hosting)

Parameters
[in]webSocketHandle to a WebSocket
[in]hostNULL-terminated string containing the hostname
Returns
Error code

Definition at line 282 of file web_socket.c.

◆ webSocketSetOrigin()

error_t webSocketSetOrigin ( WebSocket webSocket,
const char_t origin 
)

Set the origin header field.

Parameters
[in]webSocketHandle to a WebSocket
[in]originNULL-terminated string containing the origin
Returns
Error code

Definition at line 307 of file web_socket.c.

◆ webSocketSetSubProtocol()

error_t webSocketSetSubProtocol ( WebSocket webSocket,
const char_t subProtocol 
)

Set the sub-protocol header field.

Parameters
[in]webSocketHandle to a WebSocket
[in]subProtocolNULL-terminated string containing the sub-protocol
Returns
Error code

Definition at line 332 of file web_socket.c.

◆ webSocketSetTimeout()

error_t webSocketSetTimeout ( WebSocket webSocket,
systime_t  timeout 
)

Set timeout value for blocking operations.

Parameters
[in]webSocketHandle to a WebSocket
[in]timeoutMaximum time to wait
Returns
Error code

Definition at line 257 of file web_socket.c.

◆ webSocketShutdown()

error_t webSocketShutdown ( WebSocket webSocket)

Gracefully close a WebSocket connection.

Parameters
[in]webSocketHandle to a WebSocket

Definition at line 1471 of file web_socket.c.

◆ webSocketUpgradeSecureSocket()

WebSocket* webSocketUpgradeSecureSocket ( Socket socket,
TlsContext tlsContext 
)

Upgrade a secure socket to a secure WebSocket.

Parameters
[in]socketHandle referencing the socket
[in]tlsContextPointer to the TLS context
Returns
Handle referencing the new WebSocket

Definition at line 194 of file web_socket.c.

◆ webSocketUpgradeSocket()

WebSocket* webSocketUpgradeSocket ( Socket socket)

Upgrade a socket to a WebSocket.

Parameters
[in]socketHandle referencing the socket
Returns
Handle referencing the new WebSocket

Definition at line 155 of file web_socket.c.

Variable Documentation

◆ __packed_struct

typedef __packed_struct
Initial value:
{
uint8_t opcode : 4

WebSocket frame.

Definition at line 306 of file web_socket.h.

◆ extPayloadLen

uint8_t extPayloadLen[]

Definition at line 321 of file web_socket.h.

◆ fin

uint8_t fin

Definition at line 317 of file web_socket.h.

◆ mask

uint8_t mask

Definition at line 319 of file web_socket.h.

◆ payloadLen

uint8_t payloadLen

Definition at line 318 of file web_socket.h.

◆ reserved

uint8_t reserved

Definition at line 316 of file web_socket.h.

◆ WebSocketFrame

WebSocketFrame

Definition at line 322 of file web_socket.h.

◆ webSockRandCallback

WebSocketRandCallback webSockRandCallback
extern

Definition at line 52 of file web_socket.c.

uint8_t opcode
Definition: dns_common.h:188