[Libwebsockets] Proper Close frame control and LWS_WRITE_CLOSE

Andy Green andy at warmcat.com
Sat Dec 26 11:40:34 CET 2015

Hi -

I just added proper ws close frame support, with implementations in the 
test code and test html.


You can get notified of the peer closing (with his code + reason) in a 
callback, and when you're going to close by returning nonzero from the 
callback, you can now set the callback code and reason array that will 
be given to your peer.

Along with that I also today was able to deprecate 
LWS_SEND_BUFFER_POST_PADDING: it's still there in libwebsockets.h but 
set to 0, and removed from everywhere else in the library and test apps.


The only thing in lws that needed POST buffer space was LWS_WRITE_CLOSE 
(lws_write() option enum for sending a close frame).  Close is not 
supported in userland in lws anyway, the only way to close is ask the 
callback caller to do it, and he runs his own close processing from scratch.

So I have removed LWS_WRITE_CLOSE from libwebsockets.h on the 
expectation the union of the number of people using it (it would not 
have worked for, eg, setting the close code... would have duplicated 
close frames...) and using stock lws (ie, did not locally fix those 
problems in the library) is zero.

But just in case... is anyone actually using LWS_WRITE_CLOSE with stock lws?


More information about the Libwebsockets mailing list