[Libwebsockets] How to close the ws connection properly

Chropin Hu chropinhu at gmail.com
Wed Jul 18 10:04:51 CEST 2018


Dear All,
       How to close the ws connection from the server side?
       currently, I just call the following funtion at stand alone thread,
                   lws_close_reason(g_wsi_test_close,
LWS_CLOSE_STATUS_NORMAL,
(unsigned char *)"seeya", 5);
   lws_callback_on_writable(g_wsi_test_close);

        then, handle LWS_CALLBACK_SERVER_WRITEABLE msg like this,
               case LWS_CALLBACK_SERVER_WRITEABLE:
case LWS_CALLBACK_HTTP_WRITEABLE:
{
if (lws_get_close_length(wsi))
{
return -1;
}
}
      It` seems work well,  the connection closed. but I am not sure for
this.
      are there other ways to close the ws connection from the server side?

Best Wishes,
Chropin.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20180718/19bad7ec/attachment.html>


More information about the Libwebsockets mailing list