[Libwebsockets] Closing client connection by server

Andy Green andy at warmcat.com
Fri Jan 15 13:40:43 CET 2016

On January 15, 2016 12:16:52 PM GMT+00:00, techi eth <techieth at gmail.com> wrote:
>What is the way for server to close client connection ?

Just return nonzero from the callback.

You can set the close reason just before returning nonzero...

/** * lws_close_reason - Set reason and aux data to send with Close packet
 * If you are going to return nonzero from the callback
 * requesting the connection to close, you can optionally
 * call this to set the reason the peer will be told if
 * possible.
 * @wsi: The websocket connection to set the close reason on
 * @status: A valid close status from websocket standard
 * @buf: NULL or buffer containing up to 124 bytes of auxiliary data
 * @len: Length of data in @buf to send
lws_close_reason(struct lws *wsi, enum lws_close_status status, unsigned char *buf, size_t len);


>Libwebsockets mailing list
>Libwebsockets at ml.libwebsockets.org

More information about the Libwebsockets mailing list