Functions
WebSocket.h File Reference
#include "MQTTPacket.h"
Include dependency graph for WebSocket.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define WebSocket_OP_CONTINUE   0x0 /* 0000 - continue frame */
 
#define WebSocket_OP_TEXT   0x1 /* 0001 - text frame */
 
#define WebSocket_OP_BINARY   0x2 /* 0010 - binary frame */
 
#define WebSocket_OP_CLOSE   0x8 /* 1000 - close frame */
 
#define WebSocket_OP_PING   0x9 /* 1001 - ping frame */
 
#define WebSocket_OP_PONG   0xA /* 1010 - pong frame */
 
#define WebSocket_CLOSE_NORMAL   1000
 
#define WebSocket_CLOSE_GOING_AWAY   1001
 
#define WebSocket_CLOSE_PROTOCOL_ERROR   1002
 
#define WebSocket_CLOSE_UNKNOWN_DATA   1003
 
#define WebSocket_CLOSE_RESERVED   1004
 
#define WebSocket_CLOSE_NO_STATUS_CODE   1005 /* reserved: not to be used */
 
#define WebSocket_CLOSE_ABNORMAL   1006 /* reserved: not to be used */
 
#define WebSocket_CLOSE_BAD_DATA   1007
 
#define WebSocket_CLOSE_POLICY   1008
 
#define WebSocket_CLOSE_MSG_TOO_BIG   1009
 
#define WebSocket_CLOSE_NO_EXTENSION   1010
 
#define WebScoket_CLOSE_UNEXPECTED   1011
 
#define WebSocket_CLOSE_TLS_FAIL   1015 /* reserved: not be used */
 

Functions

void WebSocket_close (networkHandles *net, int status_code, const char *reason)
 
int WebSocket_connect (networkHandles *net, const char *uri)
 
size_t WebSocket_framePos ()
 
void WebSocket_framePosSeekTo (size_t)
 
int WebSocket_getch (networkHandles *net, char *c)
 receives 1 byte from a socket More...
 
char * WebSocket_getdata (networkHandles *net, size_t bytes, size_t *actual_len)
 receives data from a socket. It should receive all data from the socket that is immediately available. Because it is encapsulated in websocket frames which cannot be More...
 
int WebSocket_proxy_connect (networkHandles *net, int ssl, const char *hostname)
 
int WebSocket_putdatas (networkHandles *net, char **buf0, size_t *buf0len, PacketBuffers *bufs)
 
void WebSocket_terminate (void)
 
int WebSocket_upgrade (networkHandles *net)
 

Macro Definition Documentation

#define WebScoket_CLOSE_UNEXPECTED   1011

Definition at line 49 of file WebSocket.h.

#define WebSocket_CLOSE_ABNORMAL   1006 /* reserved: not to be used */

Definition at line 44 of file WebSocket.h.

#define WebSocket_CLOSE_BAD_DATA   1007

Definition at line 45 of file WebSocket.h.

#define WebSocket_CLOSE_GOING_AWAY   1001

Definition at line 39 of file WebSocket.h.

#define WebSocket_CLOSE_MSG_TOO_BIG   1009

Definition at line 47 of file WebSocket.h.

#define WebSocket_CLOSE_NO_EXTENSION   1010

Definition at line 48 of file WebSocket.h.

#define WebSocket_CLOSE_NO_STATUS_CODE   1005 /* reserved: not to be used */

Definition at line 43 of file WebSocket.h.

#define WebSocket_CLOSE_NORMAL   1000

Various close status codes

Definition at line 38 of file WebSocket.h.

#define WebSocket_CLOSE_POLICY   1008

Definition at line 46 of file WebSocket.h.

#define WebSocket_CLOSE_PROTOCOL_ERROR   1002

Definition at line 40 of file WebSocket.h.

#define WebSocket_CLOSE_RESERVED   1004

Definition at line 42 of file WebSocket.h.

#define WebSocket_CLOSE_TLS_FAIL   1015 /* reserved: not be used */

Definition at line 50 of file WebSocket.h.

#define WebSocket_CLOSE_UNKNOWN_DATA   1003

Definition at line 41 of file WebSocket.h.

#define WebSocket_OP_BINARY   0x2 /* 0010 - binary frame */

Definition at line 28 of file WebSocket.h.

#define WebSocket_OP_CLOSE   0x8 /* 1000 - close frame */

Definition at line 29 of file WebSocket.h.

#define WebSocket_OP_CONTINUE   0x0 /* 0000 - continue frame */

WebSocket op codes

Definition at line 26 of file WebSocket.h.

#define WebSocket_OP_PING   0x9 /* 1001 - ping frame */

Definition at line 30 of file WebSocket.h.

#define WebSocket_OP_PONG   0xA /* 1010 - pong frame */

Definition at line 31 of file WebSocket.h.

#define WebSocket_OP_TEXT   0x1 /* 0001 - text frame */

Definition at line 27 of file WebSocket.h.

Function Documentation

void WebSocket_close ( networkHandles net,
int  status_code,
const char *  reason 
)

closes a websocket connection

Parameters
[in,out]netstructure containing network connection
[in]status_codewebsocket close status code
[in]reasonreason for closing connection (optional)

Definition at line 521 of file WebSocket.c.

int WebSocket_connect ( networkHandles net,
const char *  uri 
)

sends out a websocket request on the given uri

Parameters
[in]netnetwork connection
[in]uriuri to connect to
Return values
SOCKET_ERRORon failure
1on success
See also
WebSocket_upgrade

Definition at line 383 of file WebSocket.c.

size_t WebSocket_framePos ( )

Definition at line 634 of file WebSocket.c.

void WebSocket_framePosSeekTo ( size_t  )

Definition at line 647 of file WebSocket.c.

int WebSocket_getch ( networkHandles net,
char *  c 
)

receives 1 byte from a socket

Parameters
[in,out]netnetwork connection
[out]cbyte that was read
Return values
SOCKET_ERRORon error
TCPSOCKET_INTERRUPTEDno data available
TCPSOCKET_COMPLETEon success
See also
WebSocket_getdata

Definition at line 589 of file WebSocket.c.

char* WebSocket_getdata ( networkHandles net,
size_t  bytes,
size_t *  actual_len 
)

receives data from a socket. It should receive all data from the socket that is immediately available. Because it is encapsulated in websocket frames which cannot be

Parameters
[in,out]netnetwork connection
[in]bytesamount of data to get (0 if last packet)
[out]actual_lenamount of data read
Returns
a pointer to the read data
See also
WebSocket_getch

Definition at line 669 of file WebSocket.c.

int WebSocket_proxy_connect ( networkHandles net,
int  ssl,
const char *  hostname 
)

Notify the IP address and port of the endpoint to proxy, and wait connection to endpoint.

Parameters
[in]netnetwork connection to proxy.
[in]sslenable ssl.
[in]hostnamehostname of endpoint.
Return values
SOCKET_ERRORfailed to network connection
0connection to endpoint

Definition at line 1445 of file WebSocket.c.

int WebSocket_putdatas ( networkHandles net,
char **  buf0,
size_t *  buf0len,
PacketBuffers bufs 
)

writes data to a socket (websocket header will be prepended if required)

Warning
buf0 will be expanded (backwords before buf0 buffer, to add a websocket frame header to the data if required). So use WebSocket_calculateFrameHeader, to determine if extra space is needed before the buf0 pointer.
Parameters
[in,out]netnetwork connection
[in,out]buf0first buffer
[in]buf0lensize of first buffer
[in]countnumber of payload buffers
[in,out]buffersarray of paylaod buffers
[in]buflensarray of payload buffer sizes
[in]freeDataarray indicating to free payload buffers
Returns
amount of data wrote to socket
See also
WebSocket_calculateFrameHeaderSize

Definition at line 938 of file WebSocket.c.

void WebSocket_terminate ( void  )

releases resources used by the websocket sub-system

Definition at line 1257 of file WebSocket.c.

int WebSocket_upgrade ( networkHandles net)

handles the websocket upgrade response

Parameters
[in,out]netnetwork connection to upgrade
Return values
SOCKET_ERRORfailed to upgrade network connection
TCPSOCKET_INTERRUPTEDupgrade not complete, but not failed. Try again
1socket upgraded to use websockets
See also
WebSocket_connect

Definition at line 1306 of file WebSocket.c.



plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 04:02:49