---
name: "wslay_event_send"
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_send"
---

# wslay\_event\_send(3)

Send any pending messages

## NAME

wslay\_event\_send - Send any pending messages

## SYNOPSIS

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

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

  ## DESCRIPTION

*wslay\_event\_send()* sends queued messages to peer. When sending a message, it uses **wslay\_event\_send\_callback** function. Single call of *wslay\_event\_send()* sends multiple messages until **wslay\_event\_send\_callback** sets error code **WSLAY\_ERR\_WOULDBLOCK**.

If *ctx* is initialized for WebSocket client use, *wslay\_event\_send()* uses **wslay\_event\_genmask\_callback** to get new mask key.

When a message queued using **wslay\_event\_queue\_fragmented\_msg()** is sent, *wslay\_event\_send()* invokes **wslay\_event\_fragmented\_msg\_callback** for that message.

After close control frame is sent, this function calls **wslay\_event\_set\_write\_enabled()** with second argument 0 to disable further transmission to peer.

If there are any pending messages, **wslay\_event\_want\_write()** returns 1, otherwise returns 0.

In case of a fatal error which leads to negative return code, this function calls **wslay\_event\_set\_write\_enabled()** with second argument 0 to disable further transmission to peer.

## RETURN VALUE

*wslay\_event\_send()* 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\_send()* and must close WebSocket connection.

## SEE ALSO

**wslay\_event\_queue\_fragmented\_msg()**, **wslay\_event\_set\_write\_enabled()**, **wslay\_event\_want\_write()**

## AUTHOR

Tatsuhiro Tsujikawa

## COPYRIGHT

2012, 2015, Tatsuhiro Tsujikawa
