WSLAY_EVENT_RECV(3) wslay WSLAY_EVENT_RECV(3)

wslay_event_recv - Receive messages

#include <wslay/wslay.h>

wslay_event_recv() receives messages from peer. When receiving messages, it uses wslay_event_recv_callback function. Single call of this function receives multiple messages until wslay_event_recv_callback function sets error code WSLAY_ERR_WOULDBLOCK.

wslay_event_recv() calls following callback functions for their own event (See wslay_event_context_server_init() or wslay_event_context_client_init() for the details of each callbacks).

Called when a new frame starts to be received.
Called when a new frame starts to be received.
Called when a chunk of frame payload is received.
Called when a frame is completely received.
Called when a message is completely received.

When close control frame is received, this function automatically queues close control frame. Also this function calls wslay_event_set_read_enabled() with second argument 0 to disable further read from peer.

When ping control frame is received, this function automatically queues pong control frame.

In case of a fatal error which leads to negative return code, this function calls wslay_event_set_read_enabled() with second argument 0 to disable further read from peer.

wslay_event_recv() returns 0 if it succeeds, or one of the following negative error codes:

User defined callback function is failed.
Out of memory.

When negative error code is returned, application must not make any further call of wslay_event_recv() and must close WebSocket connection.

wslay_event_set_read_enabled()

Tatsuhiro Tsujikawa

2012, 2015, Tatsuhiro Tsujikawa

June 20, 2020 1.1.1