QUIC transports
dnet provides wrappers around Quinn primitives. The QUIC implementation includes both reliable stream-based transports over SendStream/RecvStream and an unreliable datagram transport over Connection.
Available transports
QuicFramedTransport- framed transport for QUIC streams.QuicTransport- length-delimited transport for QUIC streams.QuicUnreliableTransport- unreliable datagram transport built on QUIC datagrams.
Reliable QUIC streams
QuicTransport is the most convenient option for typical message passing over QUIC streams. It composes QuicFramedTransport with dnet::io::length_delimited::Codec.
QuicTransport supports:
- bidirectional streams (wrapping
SendStreamandRecvStream). - unidirectional send-only and receive-only streams (wrapping
SendStreamorRecvStream). - buffered versions for better throughput on many small messages.
- configurable maximum message length.
Note
This is a reliable transport.
Reliable delivery and in-order delivery are handled by QUIC stream semantics.
Unreliable QUIC datagrams
QuicUnreliableTransport wraps a quinn::Connection and uses QUIC datagrams for message transport.
This transport inherits QUIC datagram semantics:
- unreliable: messages may be dropped.
- unordered: messages can arrive out of order.
- duplicate delivery is possible.
- messages are bounded by the underlying datagram size.
QuicUnreliableTransport can be configured with Configuration to:
- use
Connection::send_datagram_waitwhenwait_after_sendis enabled. - optionally close the underlying connection on transport drop or close.
Warning
This is an unreliable transport.
Messages may be dropped, arrive out of order, or be delivered multiple times.
When to use which transport
- Use
QuicTransportwhen you need a reliable, stream-based message channel. - Use
QuicFramedTransportwhen you want a custom framing codec on top of QUIC streams. - Use
QuicUnreliableTransportwhen you want datagram-style messaging with lower latency and no reliability guarantees.
Example
See QUIC example.