A lightweight, multithreaded TCP server built with Rust's standard library. It accepts client connections, reads incoming data, logs messages, and responds with Hello there!.
- TCP communication using
std::net. - Thread-per-connection concurrency.
- Modular and organized project structure.
- No external dependencies.
| Setting | Default |
|---|---|
| IP Address | 127.0.0.1 |
| Port | 8080 |
| Buffer Size | 1024 bytes |
| Response | Hello there! |
| Protocol | TCP |
The server listens on the local loopback interface and accepts connections from the same machine.
src/
├── main.rs # Application entry point
├── config.rs # Server configuration
├── constants.rs # Shared constants
├── utils.rs # Utility functions
└── server/
├── mod.rs # Listener and connection management
└── client.rs # Client communication
Run the server:
cargo runTest with Netcat in another terminal:
nc 127.0.0.1 8080Type a message and press Enter. The server responds with:
Hello there!
Verify the listening port:
ss -ltnp | grep ':8080'- The server binds to the configured address and listens for connections.
- Each accepted connection is handled in a separate thread.
- The server reads and logs the received data.
- It sends the predefined response and finishes handling the connection.
- Reads only once per connection.
- Sends one response per connection.
- Uses an unbounded thread-per-connection model.
- Implements raw TCP, not HTTP.