websocketd listens for WebSocket clients and runs a command per connection, piping messages to stdin and stdout lines back to the browser. No WebSocket library is needed in your program.
Overview
websocketd is a small server that exposes ordinary command-line programs over WebSockets, similar in spirit to inetd but for browser clients. Any executable that reads standard input and writes standard output can become an endpoint.
On each connection the server forks your program and tears it down when the client disconnects. Client messages arrive on stdin with a trailing newline; each stdout line becomes an outbound WebSocket text frame. STDERR can optionally be forwarded in tagged JSON.
The binary ships as a single downloadable executable for Linux, macOS, and Windows with minimal dependencies. It can also serve static files, route different programs to different URLs, run classic CGI, terminate TLS, enforce origin checks, and bind a Unix domain socket for local-only access.
A built-in developer console lets you test scripts before writing JavaScript clients. Examples cover many languages because the server stays language-agnostic.
Key features
- One process per WebSocket connection
- Language-agnostic stdio bridging
- Static file and CGI modes
- HTTPS and WSS support
- Origin restriction options
- Unix domain socket binding
- Optional stderr forwarding
- Built-in WebSocket debug console
Use cases
- Browser-driven CLI tools
- Live scripting demos
- Simple interactive backends
- Prototyping real-time UIs
- Teaching WebSocket basics