Skip to main content

Crate quinn_shared_socket

Crate quinn_shared_socket 

Source
Expand description

Adapter that exposes a virtual_socket::VirtualUdpSocket as a quinn::AsyncUdpSocket, so a quinn::Endpoint can run on a UDP socket that is shared with other consumers.

Typical setup:

  1. A “router” task owns the physical tokio::net::UdpSocket and recv_froms it.
  2. Each consumer (a quinn::Endpoint, an L4 forwarder, a DNS parser, …) gets its own virtual_socket::VirtualUdpSocket backed by the same physical socket.
  3. For inbound traffic, the router applies its own demultiplex rule and pushes each datagram onto the matching virtual socket’s queue with virtual_socket::VirtualUdpSocket::enqueue_inbound.
  4. The QUIC consumer wraps its virtual socket in SharedSocket::new and hands the wrapper to quinn::Endpoint::new_with_abstract_socket. quinn then sees the virtual socket as if it were exclusive — it can demux QUIC Connection IDs internally without knowing about the shared physical layer.

For outbound, SharedSocket forwards every transmit through virtual_socket’s try_send_to, which in turn writes through to the physical socket. quinn never owns the physical socket, so other consumers can keep writing through it concurrently.

Structs§

SharedSocket
Adapter that satisfies quinn::AsyncUdpSocket for a virtual_socket::VirtualUdpSocket.