[Libwebsockets] Newbie: is it possible to geenrate data from server?

Andy Green andy at warmcat.com
Fri Sep 21 14:37:24 CEST 2018

On 21/09/2018 20:28, Stefano Mora wrote:
> Hi all,
> I’m developing a simple websocket server based on minimal sample.
> No problem when I need to reply to client but I’d like to generate data 
> from server and push them to client.
> Is it possible?

Sure... the client has to reach out first though and establish the ws 

> Which wsi structure do I need to point ?

If I understand you, you want the client to connect and then wait until 
the server decides something exciting happened and send a ws message.

When the server wants to talk to the client, he just has to either call
lws_callback_on_writable() or similar api


...if the guy who decides it should happen is on the same thread as the 
lws service, or if the decision is on another thread, then 
lws_cancel_service() to wake the service thread(s) and have them realize 
there is something to do.

for an example of the latter.


> Thanks!
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> https://libwebsockets.org/mailman/listinfo/libwebsockets

More information about the Libwebsockets mailing list