Skip to content

0xGaspar/rs-websocket-chat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rs-websocket-chat

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.

What it does

  • 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

Running

cargo run

Then connect with any WebSocket client, e.g. websocat:

websocat ws://127.0.0.1:10000

Dependencies

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

Disclaimer

This is a learning project, not production-ready software. It intentionally avoids abstractions to make the underlying protocol mechanics visible.

License

MIT — see LICENSE.

About

A learning project — a minimal WebSocket chat server written in Rust from scratch.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages