An asynchronous TCP chat server built in Rust, designed to demonstrate concurrency, networking, and clean system architecture using Tokio.
This project focuses on correctness, clarity, and real-world async patterns rather than UI or frameworks.
- Async networking with Tokio (
async/await) - Concurrent client handling using lightweight tasks
- Clean modular architecture (server, client, message handling)
- Structured logging with
tracing - Designed to be extensible (broadcasting, rooms, auth, protocols)
This repository showcases:
- How to design a long-running async TCP server in Rust
- Safe concurrency and task spawning
- Separation of concerns in systems code
- Practical error handling and observability
- Production-oriented Rust patterns (no
println!debugging)
It is intentionally framework-light to emphasize core systems understanding.
src/
βββ main.rs # Application entrypoint, logging, startup
βββ server.rs # TCP listener and connection accept loop
βββ client.rs # Per-client connection handling
βββ message.rs # Message types / protocol (extensible)
βββ state.rs # Shared chat state (for future features)
Each module has a single responsibility, making the system easy to reason about and extend.
- Rust (stable)
- Cargo
cargo runServer starts on:
127.0.0.1:8080
Connect with a client
nc 127.0.0.1 8080
Multiple clients can connect concurrently.
Tech Stack
Language: Rust
Async Runtime: Tokio
Logging: tracing / tracing-subscriber
Concurrency Model: async tasks, non-blocking I/O
Current Behavior
Accepts multiple TCP clients concurrently
Reads messages from clients
Echoes messages back (baseline behavior)
Logs connection lifecycle events
This forms a solid foundation for richer chat semantics.
Planned Extensions
Message broadcasting to all connected clients
Chat rooms / channels
Message protocol with enums & serialization
Graceful shutdown handling
Load & stress testing
Authentication / authorization
π Related Projects
Async Pipeline (Rust): High-throughput async processing architecture