Http + ws on same port

Without using nginx or some type of port forwarding, is it possible to run http and websocket on the same port?

This requires something called 'upgrading' a http connection, to take it from http to websocket.

The closest I have found is this blog post:

but I don't see how to get from the code fragment to actual working code. (Also, it seems to be using hyper 0.11 instead of hyper 0.12).

Question:

Is there working code anywhere of http + websocket on same port?

actix-web (Websockets) let you do that easily.

Does this upgrade example from hyper help?

https://github.com/hyperium/hyper/blob/fea29b29e2bbbba10760917a234a8cf4a6133be4/examples/upgrades.rs

I saw this example before, but could not figure out where the websocket is. I found nothing searching that page for "websocket" and "ws"

I'm new to the rust ecosystem. Can you please point out:

  1. what struct/'noun' is websocket in that example
  2. where the open, send, recv are?

Thanks!

Yes, it doesn't show the WS part, only the upgrade part.

The second part to look at is something like this: websocket::server::upgrade - Rust

(Sorry for the terse reply, hopefully someone can give a more detailed answer)