(LWS) is a flexible, lightweight pure C library for implementing modern network protocols easily with a tiny footprint, using a nonblocking event loop. It has been developed continuously since 2010 and is used in tens of millions of devices and by thousands of developers around the world.
LWS is Free Software using the MIT license.
git clone https://libwebsockets.org/repo/libwebsockets
LWS Core code handles generic socket lifecycle, tls, vhosts, service threads, timers, unix domain sockets, SOCKS5 etc.
"Roles" are wire protocol implementations on top of that, isolated via an ops struct:
|raw tcp / udp / file||⭘||⭘|
LWS supports optional TLS for client or server (including client certs) on any role.
New roles can be added cleanly to lws.
TLS (SSL) support
LWS equally supports OpenSSL
-based and mbedTLS
tls backend libraries. OpenSSL is faster but requires
more memory; for constrained devices, you can trade off speed for memory footprint by selecting mbedTLS as the TLS backend.
LWS provides generic apis to access hashing, RSA, X509 and tls library features independent of the tls backend.
User code interfaces to LWS roles by providing a "protocol", including callback for events the code is interested in customizing.
Event loop libraries
LWS defaults to using poll(), however glib
event libraries are all supported.
LWS may both provide an internal loop, or participate cleanly in an external, "foreign" loop. New event libs
can be added cleanly to lws
LWS user code does not have to be customized depending on the event loop in use. For example LWS provides a generic
high-resolution timer for each connection to arrange for delayed callbacks, hiding the details of the exact
implementation depending on the chosen event loop.