Skip to content

Repository files navigation

tiny-websocket

A tiny, embeddable C99 WebSocket server library.

Features

  • Server-side WebSocket handshake with path and optional subprotocol negotiation.
  • IPv4/IPv6/UNIX-domain sockets.
  • User-supplied event-loop hooks for read/write readiness and timers.

Build

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build

To install:

cmake --install build

Headers can be included with #include <tiny-websocket/tws.h>

Usage and example

Please refer to tws.h for detailed API documentation.
Please refer to test_tws.c for an echo server example.

Tests

  1. Install tev from source.
  2. Build tests:
cmake -S test -B test/build
cmake --build test/build
  1. Start the echo server
./test/build/test_tws       # starts echo server on 127.0.0.1:24371 path /ws
  1. Run the JavaScript client (in another session)
cd test && npm install      # install JS deps (once)
node test_tws.js            # runs the WebSocket client against the server

Acknowledgement

This project uses Brad Conte's crypto-algorithms for websocket handshake purposes.

About

A minimum WebSocket server.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages