[Libwebsockets] Returning wrong protocol number when initialising the context

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

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?

#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[]) {
  std::vector<lws_protocols> _protocols;

  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;

  if (context==NULL) {
    printf("libwebsocket init failed\n");
    return -1;

-------------- 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