[Libwebsockets] Passing data to LWS_CALLBACK_SERVER_WRITEABLE

Ars Comm - Ciro Ferraiuolo c.ferraiuolo at arscomm.it
Wed Dec 17 14:17:09 CET 2014


Hi, I need to send some data from the server to the client. I've read that "Directly performing websocket actions from other threads is not allowed". So I'm calling libwebsocket_callback_on_writable to get the   LWS_CALLBACK_SERVER_WRITEABLE callback. Now my question is, how can i pass the data to send to the callback? It's ok to simply store it into a global array accessed by the callback? What if another thread gets access to it before the callback is called? But the readme.coding says "Generating what to write and sending it should be done in the ...WRITEABLE callback​", how can i do that?​ I've got the data ready at some point in my code, how can I generate what to write in the WRITEABLE callback?

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://libwebsockets.org/pipermail/libwebsockets/attachments/20141217/d3de88d9/attachment.html>


More information about the Libwebsockets mailing list