[Libwebsockets] Returning wrong protocol number when initialising the context

Gilles Printemps gprintemps at gmail.com
Mon Nov 18 11:55:33 CET 2019


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?
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);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20191118/72b4163e/attachment.htm>


More information about the Libwebsockets mailing list