Created this purely for fun because it seemed fun to implement a chat server with the std library only and learning a bit about how UDP works.
Setup tailscale with a friend(s) and enjoy sending messages on your own channel.
Everything following this line is chatgpt generated
- UDP Communication: Utilizes UDP for low-latency, connectionless communication between clients and server.
- Concurrent Message Broadcasting: Leverages Rust's threading and synchronization primitives to handle concurrent message broadcasts to connected clients.
- Dynamic Client Management: Automatically adds new clients to the broadcast list and manages them throughout the session.
Before running the application, ensure you have Rust installed on your system. Visit the official Rust website for installation instructions.
- Clone the Repository
git clone <repository-url>
cd rust-udp-chat-
Configuration
Currently, the application requires manually setting the destination address ('DEST_ADDR') in the code. This is the address and port the server listens on, e.g., '"127.0.0.1:34254"'. In future versions, this will be configurable via an environment variable.
-
Building the Project
Compile the project with Rust's package manager, Cargo.
cargo build --releaseTo start the application, you can choose to run it in either server or client mode.
-
Edit the 'DEST_ADDR' in the source code to the address you want the server to listen on.
-
Run the server:
cargo runWhen prompted, select mode 1 for server mode.
-
Ensure 'DEST_ADDR' in the source code matches the server's listening address.
-
Run the client:
cargo runWhen prompted, select mode 2 for client mode. Enter your username and start chatting.
- Environment Variables for Configuration: Planning to allow setting the server address and port through environment variables for ease of use.
- Improved Client Management: Enhancements for better handling of client connections and disconnections.