Go to the source code of this file.
|
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) |
|
#define WebScoket_CLOSE_UNEXPECTED 1011 |
#define WebSocket_CLOSE_ABNORMAL 1006 /* reserved: not to be used */ |
#define WebSocket_CLOSE_BAD_DATA 1007 |
#define WebSocket_CLOSE_GOING_AWAY 1001 |
#define WebSocket_CLOSE_MSG_TOO_BIG 1009 |
#define WebSocket_CLOSE_NO_EXTENSION 1010 |
#define WebSocket_CLOSE_NO_STATUS_CODE 1005 /* reserved: not to be used */ |
#define WebSocket_CLOSE_NORMAL 1000 |
Various close status codes
Definition at line 38 of file WebSocket.h.
#define WebSocket_CLOSE_POLICY 1008 |
#define WebSocket_CLOSE_PROTOCOL_ERROR 1002 |
#define WebSocket_CLOSE_RESERVED 1004 |
#define WebSocket_CLOSE_TLS_FAIL 1015 /* reserved: not be used */ |
#define WebSocket_CLOSE_UNKNOWN_DATA 1003 |
#define WebSocket_OP_BINARY 0x2 /* 0010 - binary frame */ |
#define WebSocket_OP_CLOSE 0x8 /* 1000 - close frame */ |
#define WebSocket_OP_CONTINUE 0x0 /* 0000 - continue frame */ |
#define WebSocket_OP_PING 0x9 /* 1001 - ping frame */ |
#define WebSocket_OP_PONG 0xA /* 1010 - pong frame */ |
#define WebSocket_OP_TEXT 0x1 /* 0001 - text frame */ |
void WebSocket_close |
( |
networkHandles * |
net, |
|
|
int |
status_code, |
|
|
const char * |
reason |
|
) |
| |
closes a websocket connection
- Parameters
-
[in,out] | net | structure containing network connection |
[in] | status_code | websocket close status code |
[in] | reason | reason for closing connection (optional) |
Definition at line 521 of file WebSocket.c.
sends out a websocket request on the given uri
- Parameters
-
[in] | net | network connection |
[in] | uri | uri to connect to |
- Return values
-
SOCKET_ERROR | on failure |
1 | on success |
- See also
- WebSocket_upgrade
Definition at line 383 of file WebSocket.c.
size_t WebSocket_framePos |
( |
| ) |
|
void WebSocket_framePosSeekTo |
( |
size_t |
| ) |
|
receives 1 byte from a socket
- Parameters
-
[in,out] | net | network connection |
[out] | c | byte that was read |
- Return values
-
SOCKET_ERROR | on error |
TCPSOCKET_INTERRUPTED | no data available |
TCPSOCKET_COMPLETE | on 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] | net | network connection |
[in] | bytes | amount of data to get (0 if last packet) |
[out] | actual_len | amount 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] | net | network connection to proxy. |
[in] | ssl | enable ssl. |
[in] | hostname | hostname of endpoint. |
- Return values
-
SOCKET_ERROR | failed to network connection |
0 | connection to endpoint |
Definition at line 1445 of file WebSocket.c.
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] | net | network connection |
[in,out] | buf0 | first buffer |
[in] | buf0len | size of first buffer |
[in] | count | number of payload buffers |
[in,out] | buffers | array of paylaod buffers |
[in] | buflens | array of payload buffer sizes |
[in] | freeData | array 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.
handles the websocket upgrade response
- Parameters
-
[in,out] | net | network connection to upgrade |
- Return values
-
SOCKET_ERROR | failed to upgrade network connection |
TCPSOCKET_INTERRUPTED | upgrade not complete, but not failed. Try again |
1 | socket upgraded to use websockets |
- See also
- WebSocket_connect
Definition at line 1306 of file WebSocket.c.