<div dir="ltr"><div class="gmail_default" style="font-size:x-small">Yes that is correct.</div><div class="gmail_default" style="font-size:x-small">Trigger a writeable event on your wsi, then on write return -1.<br></div><div class="gmail_default" style="font-size:x-small">You are doing it correctly.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 18, 2018 at 4:04 AM, Chropin Hu <span dir="ltr"><<a href="mailto:chropinhu@gmail.com" target="_blank">chropinhu@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Dear All,<div>       How to close the ws connection from the server side?</div><div>       currently, I just call the following funtion at stand alone thread,</div><div><font color="#0000ff">                   lws_close_reason(g_wsi_test_<wbr>close, LWS_CLOSE_STATUS_NORMAL,</font></div><div><font color="#0000ff"><span style="white-space:pre-wrap">                                      </span> (unsigned char *)"seeya", 5);</font></div><div><font color="#0000ff"><span style="white-space:pre-wrap">              </span>   lws_callback_on_writable(g_<wbr>wsi_test_close);</font></div><div><font color="#0000ff">       </font></div><div>        then, handle <span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">LWS_CALLBACK_SERVER_<wbr>WRITEABLE msg like this,</span></div><div><div>               <font color="#0000ff">case LWS_CALLBACK_SERVER_WRITEABLE:</font></div><div><font color="#0000ff"><span style="white-space:pre-wrap">            </span>case LWS_CALLBACK_HTTP_WRITEABLE:</font></div><div><font color="#0000ff"><span style="white-space:pre-wrap">             </span>{</font></div><div><font color="#0000ff"><span style="white-space:pre-wrap">                     </span>if (lws_get_close_length(wsi))</font></div><div><font color="#0000ff"><span style="white-space:pre-wrap">                        </span>{</font></div><div><font color="#0000ff"><span style="white-space:pre-wrap">                             </span>return -1;</font></div><div><font color="#0000ff"><span style="white-space:pre-wrap">                    </span>}</font></div><div><font color="#0000ff"><span style="white-space:pre-wrap">             </span>}</font></div></div><div><font color="#0000ff">      </font><font color="#000000">It` seems work well,  the connection closed. but I am not sure for this.</font></div><div><font color="#000000">      are there other ways to close the ws connection from the server side?</font></div><div><font color="#000000"><br></font></div><div><font color="#000000">Best Wishes,</font></div><div><font color="#000000">Chropin.</font></div><div><font color="#000000">      </font></div></div>
<br>______________________________<wbr>_________________<br>
Libwebsockets mailing list<br>
<a href="mailto:Libwebsockets@ml.libwebsockets.org">Libwebsockets@ml.<wbr>libwebsockets.org</a><br>
<a href="https://libwebsockets.org/mailman/listinfo/libwebsockets" rel="noreferrer" target="_blank">https://libwebsockets.org/<wbr>mailman/listinfo/libwebsockets</a><br>
<br></blockquote></div><br></div>