---
name: "wslay_event_recv"
section: "3"
platform: "linux"
package: "libwslay"
version: "1.1.1-7"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/wslay_event_recv"
---

# wslay\_event\_recv(3)

Receive messages

## NAME

wslay\_event\_recv - Receive messages

## SYNOPSIS

\#include \<wslay/wslay.h\>

- **int wslay\_event\_recv(wslay\_event\_context\_ptr *ctx*)**

  ## DESCRIPTION

*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).

- **wslay\_event\_on\_frame\_recv\_start\_callback**

  Called when a new frame starts to be received.

- **wslay\_event\_on\_frame\_recv\_start\_callback**

  Called when a new frame starts to be received.

- **wslay\_event\_on\_frame\_recv\_chunk\_callback**

  Called when a chunk of frame payload is received.

- **wslay\_event\_on\_frame\_recv\_end\_callback**

  Called when a frame is completely received.

- **wslay\_event\_on\_msg\_recv\_callback**

  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.

## RETURN VALUE

*wslay\_event\_recv()* returns 0 if it succeeds, or one of the following negative error codes:

- **WSLAY\_ERR\_CALLBACK\_FAILURE**

  User defined callback function is failed.

- **WSLAY\_ERR\_NOMEM**

  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.

## SEE ALSO

**wslay\_event\_set\_read\_enabled()**

## AUTHOR

Tatsuhiro Tsujikawa

## COPYRIGHT

2012, 2015, Tatsuhiro Tsujikawa
