[Libwebsockets] Returning wrong protocol number when initialising the context

Andy Green andy at warmcat.com
Mon Nov 18 12:03:38 CET 2019



On 11/18/19 10:55 AM, Gilles Printemps wrote:
> Hi,
> When I'm executing the following example (using libwebsockets 3.2.0), I 
> got the following output through the logs
> *"Creating Vhost 'default' port 9000, 5 protocols, IPv6 off"*
> Can someone explain why "5 protocols" are returned?

If you're curious about what's going on in lws you can increase the log 
verbosity, it reports what vhosts it's creating at startup using INFO 
log level.

Select -DCMAKE_BUILD_TYPE=DEBUG at cmake and recook lws, then enable 
LLL_INFO logging.

-Andy

> BR
> 
> 
> #include <vector>
> #include <libwebsockets.h>
> 
> static int WSCallback(struct lws *wsi,enum lws_callback_reasons 
> reason,void *session,void *data,size_t len) {}
> 
> int main(int argc, char* argv[]) {
>    lws_set_log_level(12,NULL);
>    std::vector<lws_protocols> _protocols;
>    _protocols.push_back({"ZWave",WSCallback,128,128,0,nullptr});
> 
>    struct lws_context *context=NULL;
>    struct lws_context_creation_info info;
>    memset(&info, 0, sizeof info);
>    info.port = 9000;
>    info.protocols = _protocols.data();
>    info.gid = -1;
>    info.uid = -1;
>    info.options = 0;
>    context=lws_create_context(&info);
> 
>    if (context==NULL) {
>      printf("libwebsocket init failed\n");
>      return -1;
>    }
> 
>    lws_context_destroy(context);
> }
> 
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> https://libwebsockets.org/mailman/listinfo/libwebsockets
> 


More information about the Libwebsockets mailing list