Since your goal is to create a high-performance web socket server, starting with an HTTP server such as Iron may not make sense. (Iron is based on Hyper , which claims to be a "fast and proper HTTP implementation.") I would recommend taking a look at tokio , which was designed as an "event-driven asynchronous platform" and used by Hyper and Iron.
WebSockets requires a different protocol that creates a two-way interactive communication session. From the Mozilla docs :
You can send messages to the server and receive event-driven responses without requesting a response from the server.
Thus, if you do not need HTTP, then starting from a request / response-oriented server is more likely to bring more complexity than good. Although the issue of iron web sockets is still open, a recent comment notes:
Personally, I think it's pretty difficult to fit websocket into the Iron Request-Middleware-Response model. I have not seen elegant abstraction in other languages for this.
If you really want to explore the use of WebSockets with Iron, you need to expand Hyper to support WebSockets (a good discussion here ), and then access a lower level hyperlink (explained in Iron Problem No. 478 ). Once connected, the WebSocket library will be useful (although rust-websocket seems to be no longer supported).
Ultrasaurus
source share