WebSockets in Rust
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access