A. Gille
A. Gille

Reputation: 1048

Implement WebSocket and LWSWS servers in same executable with libwebsockets

I'm trying to create a Web Socket server and a LWSWS web server provided in libwebsockets v2.0.

I just need a simple web server to provide HTML/JS/CSS content to the browser and a web sockets server to work with the Web front-end.

The only doc available is really short and doesn't say anything about that, as v2.0 is brand new. The libwebsockets GitHub recommand to refer to the LWSWS example in the project, but the procedures to implement and run a server for LWSWS and a Web Socket server are not matching (the first using libuv event loop, the other using built-in libwebsockets functions).

Maybe the only solution is implementing my own http callback but I want to make sure that there's no faster solution using LWSWS.

Upvotes: 1

Views: 723

Answers (1)

A. Gille
A. Gille

Reputation: 1048

I managed to compile and run a LWSWS server from libwebsockets, embedding an HTTP Server and a Web Socket server in the same executable.

Guidelines

  1. Use code from example lwsws/main.c, and copy .h and .c depencies to compile an LWSWS server
  2. Use code from example plugin-standalone/protocol_example_standalone.c to compile your protocol plugin .dll
  3. Create a quick server and vhost configuration from lwsws/etc-lwsws-conf.d-localhost-EXAMPLE and lwsws/etc-lwsws-conf-EXAMPLE
  4. Put compiled plugins and libs at the right spot and enjoy your server

In case it might help !

Upvotes: 1

Related Questions