---
name: "wslay_event_queue_fragmented_msg_ex"
section: "3"
platform: "linux"
package: "libwslay-doc"
version: "1.1.1-4"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/wslay_event_queue_fragmented_msg_ex"
---

# wslay\_event\_queue\_fragmented\_msg\_ex(3)

Queue a fragmented message for future transmission

## NAME

wslay\_event\_queue\_fragmented\_msg\_ex - Queue a fragmented message for future transmission

## SYNOPSIS

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

- **int wslay\_event\_queue\_fragmented\_msg(wslay\_event\_context\_ptr ctx, const struct wslay\_event\_fragmented\_msg \*arg)**

  - **int wslay\_event\_queue\_fragmented\_msg\_ex(wslay\_event\_context\_ptr ctx, const struct wslay\_event\_fragmented\_msg \*arg, uint8\_t rsv)**

  ## DESCRIPTION

*wslay\_event\_queue\_fragmented\_msg()* and *wslay\_event\_queue\_fragmented\_msg\_ex()* queue a fragmented message specified in *arg*.  The *struct wslay\_event\_fragmented\_msg* is defined as:

```
union wslay_event_msg_source {
    int   fd;
    void *data;
};
struct wslay_event_fragmented_msg {
    uint8_t                             opcode;
    union wslay_event_msg_source        source;
    wslay_event_fragmented_msg_callback read_callback;
};
```

- **typedef ssize\_t (\*wslay\_event\_fragmented\_msg\_callback)(wslay\_event\_context\_ptr ctx, uint8\_t \*buf, size\_t len, const union wslay\_event\_msg\_source \*source, int \*eof, void \*user\_data)**

  The *opcode* member is the opcode of the message. The *source* member is an union and normally it contains a "source" to generate message data. The *read\_callback* is a callback function called by *wslay\_event\_send()* to read message data from *source*. The implementation of *wslay\_event\_fragmented\_msg\_callback* must store at most *len* bytes of data to *buf* and return the number of stored bytes. If all data is read (i.e., EOF), set *\*eof* to 1. If no data can be generated at the moment, return 0. If there is an error, return -1 and set error code **WSLAY\_ERR\_CALLBACK\_FAILURE** using *wslay\_event\_set\_error()*.

This function supports non-control messages only. For control frames, use *wslay\_event\_queue\_msg()* or *wslay\_event\_queue\_close()*.

This function just queues a message and does not send it. *wslay\_event\_send()* function call sends these queued messages.

*wslay\_event\_queue\_fragmented\_msg\_ex()* additionally accepts *rsv* parameter, which is a reserved bits to send. To set reserved bits, use macro **WSLAY\_RSV1\_BIT**, **WSLAY\_RSV2\_BIT**, and **WSLAY\_RSV3\_BIT**.  See *wslay\_event\_config\_set\_allowed\_rsv\_bits()* to see the allowed reserved bits to set.

## RETURN VALUE

*wslay\_event\_queue\_fragmented\_msg()* and *wslay\_event\_queue\_fragmented\_msg\_ex()* return 0 if it succeeds, or returns the following negative error codes:

- **WSLAY\_ERR\_NO\_MORE\_MSG**

  Could not queue given message. The one of possible reason is that close control frame has been queued/sent and no further queueing message is not allowed.

- **WSLAY\_ERR\_INVALID\_ARGUMENT**

  The given message is invalid; or bit is set in *rsv* which is not allowed (see *wslay\_event\_config\_set\_allowed\_rsv\_bits()*).

- **WSLAY\_ERR\_NOMEM**

  Out of memory.

## SEE ALSO

*wslay\_event\_queue\_msg()*, *wslay\_event\_queue\_msg\_ex()*, *wslay\_event\_queue\_close()*

## AUTHOR

Tatsuhiro Tsujikawa

## COPYRIGHT

2023, 2015, Tatsuhiro Tsujikawa
