In keeping with the other tutorials that we've already done, I decided that we should look at something that could be used on a network. I originally was going to do a simple web server application but I decided that that project would be better used later because there are tons of really nice libraries in Rust that help you create fairly robust and full featured web applications. I wanted the first few projects to not make use of any external libraries to show just how flexible the standard library of Rust truly is; I think that I have more or less succeeded in doing that.
In this particular project, we build two Rust projects; a server and a client. The server works by listening on a Tcp channel for any incoming messages that are streams of UTF8 characters. It uses non-blocking methods to parse these streams and then send them back to the client to show that it did receive the message. The client side works similar to a REPL (read evaluate print loop). You can enter in a message; that message is evaluated by the server then it is sent back to the client and you can enter in a new message. You may also enter the word :quit into the console to close out of the client. The server supports scaling and you could in theory use this particular code base with slight modifications on a real world server with thousands of clients. This scaling is possible because both the client and server makes use of multi-threading and channels.
While this project was arguably a little more simple then the one prior to it, I felt that it was worth doing because it allows us to explore the networking libraries that are baked into the Rust standard library in a way that is both interactive and visual. It was fun to live code this example and there were a few moments where I had to backtrack and stop the video to get the code working properly.
As an aside, I will probably have to start breaking some of these projects into multiple videos so that they aren't too long for the viewers. I do not want to create a project that is longer then 15 minutes on YouTube because I feel that that sort of removes some of the educational value from the video.
I hope you guys enjoy this video and I hope it also helps you better understand the language of Rust. There are many more projects to come.
Full Github Source Code is here
If you enjoy the video, feel free to follow me on Steemit or on YouTube to get updates on the channel as well as more content.
If you like what I do, tips and upvotes are welcome:
ETH: 0xE448a8DDA5886C49d35B191B2F20630c103024c8
LTC: LXsKxF5JhmMtKgqfcUFdvcXVwiaSqxN9cP
Also, feel free to check out my channel for videos on Go, Elixir and Elm