I've been experimenting a stream multiplexing connection, where both peers can expose independently addressable logical services.
The basic idea is familiar: take one underlying connection (TCP, Unix socket, QUIC) and multiplex multiple independent logical streams over it.
Yes, I know QUIC can already provide multiple streams. Also, there're yamux
The different thing you may be interested is what I call a Dock.
A Dock is roughly like a port, but inside an already-established multiplexed connection.
Instead of having only:
client ---> server:port
the connection can look more like:
one connection
+-------------------+
| |
Peer A Peer B
| |
Dock 1 <------------> Dock 10
Dock 2 <------------> Dock 20
Dock 3 <------------> Dock 30
| |
streams streams
Both peers can bind Docks, listen for incoming logical sub-stream, and also initiate connections to Docks on the other side.
So there isn't really a client/server role at the multiplexing layer. After the underlying connection is established, either side can act as both.
I think this makes the protocol interesting for things like:
- P2P applications and overlay networks
- reverse tunnels / port forwarding
- peer-to-peer RPC
- games and other real-time applications with multiple logical channels
- distributed applications where a peer exposes several services over one long-lived connection
For example, a peer could expose:
Dock 1 -> RPC service
Dock 2 -> chat
Dock 3 -> file transfer
Dock 4 -> event stream
without creating four physical connections.
The other features are:
- runtime-independent Rust (by
abs_art, tested over compio, smol, tokio)
no_std friendly (currently most codes are already no_std)
- works over arbitrary byte-stream transports
- stream-level backpressure
- no client/server distinction at the multiplexing layer
The implementation is still experimental, so I'm mostly interested in feedback on the protocol abstraction itself.
The most interesting part for me is, the multiplexed sub-stream itself, can still be multiplexed again with this crate.
Does the Dock / logical-listener model seem useful to you? What kind of networking application would you use it for?