diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/civetweb/docs/api/mg_websocket_write.md | |
parent | Initial commit. (diff) | |
download | ceph-upstream/16.2.11+ds.tar.xz ceph-upstream/16.2.11+ds.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/civetweb/docs/api/mg_websocket_write.md | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/civetweb/docs/api/mg_websocket_write.md b/src/civetweb/docs/api/mg_websocket_write.md new file mode 100644 index 000000000..3c7eadc77 --- /dev/null +++ b/src/civetweb/docs/api/mg_websocket_write.md @@ -0,0 +1,34 @@ +# Civetweb API Reference + +### `mg_websocket_write( conn, opcode, data, data_len );` + +### Parameters + +| Parameter | Type | Description | +| :--- | :--- | :--- | +|**`conn`**|`struct mg_connection *`|Connection on which the data must be written| +|**`opcode`**|`int`|Opcode| +|**`data`**|`const char *`|Data to be written to the client| +|**`data_len`**|`size_t`|Length of the data| + +### Return Value + +| Type | Description | +| :--- | :--- | +|`int`|Number of bytes written or an error code| + +### Description + +The function `mg_websocket_write()` sends data to a websocket client wrapped in a websocket frame. The function issues calls to [`mg_lock_connection()`](mg_lock_connection.md) and [`mg_unlock_connection()`](mg_unlock_connection.md) to ensure that the transmission is not interrupted. Data corruption can otherwise happen if the application is proactively communicating and responding to a request simultaneously. + +The function is available only when Civetweb is compiled with the `-DUSE_WEBSOCKET` option. + +The function returns the number of bytes written, **0** when the connection has been closed and **-1** if an error occurred. + +### See Also + +* [`mg_lock_connection();`](mg_lock_connection.md) +* [`mg_printf();`](mg_printf.md) +* [`mg_unlock_connection();`](mg_unlock_connection.md) +* [`mg_websocket_client_write();`](mg_websocket_client_write.md) +* [`mg_write();`](mg_write.md) |