Skip to content

danwritecode/rust_udp_chat_server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Recreating IRC from scratch with rust std lib and UDP

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

Features

  • 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.

Prerequisites

Before running the application, ensure you have Rust installed on your system. Visit the official Rust website for installation instructions.

Setup

  1. Clone the Repository
 git clone <repository-url>
 cd rust-udp-chat
  1. 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.

  2. Building the Project

    Compile the project with Rust's package manager, Cargo.

cargo build --release

Running the Application

To start the application, you can choose to run it in either server or client mode.

Server Mode

  1. Edit the 'DEST_ADDR' in the source code to the address you want the server to listen on.

  2. Run the server: cargo run

    When prompted, select mode 1 for server mode.

Client Mode

  1. Ensure 'DEST_ADDR' in the source code matches the server's listening address.

  2. Run the client: cargo run

    When prompted, select mode 2 for client mode. Enter your username and start chatting.

Future Enhancements

  • 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.

About

Recreating IRC with UDP and rust's standard lib

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages