TCP socket based chat built in Rust programming language
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
I built this chat to improve my skills on Rust programming language. feel free to use it.
The server listens on 127.0.0.1:8080.
Each connected client is handled in a separate thread.
The clients vector contains all connected clients' streams and is wrapped in an Arc<Mutex<>> for thread safety. When a message is received from a client, it's broadcasted to all other connected clients.
When a client disconnects, its stream is removed from the clients vector.
Remember, this is still a simple example and doesn't handle all edge cases, such as errors during read/write operations or handling disconnected clients gracefully. In production-level code, you'd want to add more error handling and robustness features.
Rust toolkit installed. please refer to Rust documentation
build and run
$ cargo build
If you want to execute locally in your network on several computers you might need to allow the used port on your local firewall.
- start the server (inside chat-server folder)
$ cargo run
- start the chat clients (inside chat-client folder)
$ cargo run
- [ v ] basic server and client
- Change server concurrency pattern
- Add prompt to client
- create client dedicated structures
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt
for more information.
Project Link: https://github.com/pedromiguelmiranda/another-rust-chat