This repository contains an example of a WebSocket server implementation using Rust. The server accepts incoming WebSocket connections, receives messages from clients, and broadcasts the messages to all connected clients.
- Asynchronous WebSocket server using async_std and async_tungstenite
- Accepts incoming WebSocket connections
- Receives messages from clients
- Broadcasts messages to all connected clients
- Demonstrates usage of async channels and shared state
- Rust: To install Rust, follow the instructions on the official Rust website.
- Clone the repository:
git clone https://github.com/yourusername/websocket_server_example.git cd websocket_server_example
- Build the project:
cargo build
- Run the server:
cargo run
The server will start listening on 127.0.0.1:8080
.
You can use a WebSocket client, such as websocat, to test the server. Install websocat and run the following command to connect to the server and start sending messages:
websocat ws://127.0.0.1:8080