[Libwebsockets] Help getting started with data from outside of the client callback loop

Nick Poole nickpoole at black-sphere.co.uk
Thu Aug 3 17:10:29 CEST 2017


Thanks Andy.

> You also have the option to set your own wsi user pointer for individual client connections when you create it with struct lws_client_connect_info
>
> void *userdata;
> /**< if non-NULL, use this as wsi user_data instead of malloc it */
>
> It that case you allocate it yourself and need to free it in LWS_CALLBACK_CLOSE and LWS_CALLBACK_CLIENT_CONNECTION_ERROR; lws doesn't allocate or free the user stuff if you gave your own.
I hadn't realised it was possible to pass the per-connection user-data 
in like that: I'd only seen the reference to how the protocol definition 
defines the size to malloc it to. I assume I can free it after I've 
called lws_context_destroy()?

Thanks again,

Nick




More information about the Libwebsockets mailing list