A multi-client TCP broadcast chat server built with Tokio — because writing a chat server is the best way to actually understand async Rust in practice.
Every client that connects gets its own task. Messages broadcast to everyone. Ctrl+C shuts everything down cleanly — no dropped connections, no panics, no zombie tasks.
- Multiple clients connect over TCP simultaneously
- Every message broadcasts to all connected clients
- Graceful shutdown via Ctrl+C using
CancellationToken - Each client handled in its own Tokio task
cargo run
# connect from another machine on the same network
nc <your-local-ip> <port>tokio::net::TcpListenerandTcpStreambroadcastchannel for fan-out messagingCancellationTokenfor coordinated shutdown- Concurrent task management with
JoinSet