In my previous article, I had written a very simple and basic reverse proxy. It is just like Nginx but without all the usefulness. In this new code, I have used tokio.rs. Tokio provides runtimes for asynchronous programming. A runtime bundles services together and makes a single type of (for want of a better word) process, service, runtime, etc. This makes it easier to shut down, started, etc. In the code below, I have used TcpStream and TcpListener from the tokio library and not std. I have also spawned for tokio threads and within that, tokio tasks, which are sort of like green threads, but not quite because Rust does not natively support it.
I wanted the application I write to be able to run well on a raspberry pi zero. And Rust could do all this extremely well. Apart from that, Rust is the safest language ever. And it's not like when Java says that it's secure. Rust means it and has gone above and beyond to make sure you can only write safe and secure code. It does this because it has one of the most advanced and thorough compilers, that WILL NOT compile your code unless it is safe. I choose Rust. Q.E.D.