If you work in web development, you know that WebSockets are one of the most useful protocols to speed up communication with the client. Using them allows your server to send information to the client without the latter requesting it, therefore avoiding one extra request. Rust has a great crate that allows the implementation of WebSockets, named websocket.
We will analyze a small, asynchronous WebSocket echo server example to see how it works. We will need to add websocket, futures, and tokio-core to the [dependencies] section of our Cargo.toml file. The following example has been retrieved and adapted from the asynchronous server example in the websocket crate. It uses the Tokio reactor core, which means that it requires ...