Libwebsockets a powerful and lightweight pure C library

  • I have used this library before, it's a powerful library indeed but the documentation is a bit lacking. There isn't a straightforward guide to do the most common operations, even the most simple ones like connecting a client to a server, and you're left with studying the various examples provided, each of them do things a little differently. There are also a lot of undocumented functions/constants/structs.

  • We use libwebsockets in Ardour (a cross-platform digital audio workstation) to provide the ability to create control surfaces (GUIs) within the browser. We mostly treat it as a transport layer for OSC messages, which could otherwise be transferred via UDP (if the endpoint wasn't a browser).

  • How does this fare compared to uWebSockets? https://github.com/uNetworking/uWebSockets

  • I wrote something similar, except instead of providing a library (which Libwebsockets already does a fine job of), I created a server/framework accepting shared objects as backend plugins running as dedicated threads interacting with spsc lockless ringbuffers. In other words, more or less the inverse of a library: https://github.com/wbudd/ringsocket

    I haven't been putting much time into it anymore lately, but I intend to create a bunch of language bindings for it soon so you can write plugins in other languages too such as Python, C++, Rust, etc. Should be interesting.

  • I personally prefer QtWebSockets. I've used libwebsockets before, but I found the API error prone and crusty, and ended up eventually converting it to QWebSockets. That turned out to be a good move.

  • Not a library [1], but trivial to integrate in your architecture. Just redirect stdout to gwsocket

    [1] https://gwsocket.io/

  • I remember hearing about it many years ago, and am surprised to find it alive, and well now.

    I always felt that the web people were never about performance, since there were many "pure C" webdev attempts before without much success.

    Nginx can very realistically handle 1-2M requests per minute on commodity hardware, and no customisation, and that's from the disk.

    Were somebody really serious about web performance, I think going from millions of requests per minute, to millions of requests per second is 100% possible.

    I worked on this problem around 6 years ago, when I had a task of squeezing HTTP, and network perf on some API servers close to hardware limits. The task was mostly about gluing DPDK to popular software: nginx, memcached, postgres.

    I am very enthusiastic to see Libwebsockets getting glib support. Glib is a one of a kind piece of software in the C ecosystem with which you can adopt modern programming methods, and in general approach it as you do it in a big "platform" like environment like NODEJS. Glib is really undeserving neglected, and overlooked.

  • I wish there was something like this for WebRTC data channels.

  • Has anyone used this in a multithreaded implementation, and how is/was the experience?

  • How does performance compare to a C/C++ UDP implementation?

  • This really needs to be a system library; I'm rooting for it.

  • When will people stop writing C? The memory safety issues make go, rust etc. much better solutions.