A learning project — a minimal WebSocket chat server written in Rust from scratch.
This is a personal exercise in understanding how WebSocket servers work at a low level, without relying on any high-level WebSocket framework. It implements the WebSocket handshake and framing protocol (RFC 6455) directly, and uses mio for non-blocking I/O.
- Listens for TCP connections on
127.0.0.1:10000 - Performs the HTTP Upgrade / WebSocket handshake manually (SHA-1 accept key,
101 Switching Protocols) - Parses and writes WebSocket frames (text, binary, ping/pong, close)
- Broadcasts each incoming message to all other connected clients
- Uses
mio(epoll/kqueue) for non-blocking, event-driven I/O — no async runtime
cargo runThen connect with any WebSocket client, e.g. websocat:
websocat ws://127.0.0.1:10000| Crate | Purpose |
|---|---|
mio |
Non-blocking I/O / event loop |
httparse |
Parsing the HTTP upgrade request |
sha1 |
Computing the WebSocket accept key |
base64 |
Encoding the accept key |
byteorder |
Reading/writing big-endian frame lengths |
This is a learning project, not production-ready software. It intentionally avoids abstractions to make the underlying protocol mechanics visible.
MIT — see LICENSE.