Something went wrong. Try again.
QUIC for Zig 0.17: RFC 9000-9002 with TLS 1.3, as a sans-I/O core plus a socket layer, with datagrams, multipath and raw public keys.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie <jeff@ocjtech.us>// SPDX-License-Identifier: MIT
//! QUIC with the I/O put back, for callers who want a server rather than a//! state machine.//!//! The `quic` module beside this one is sans-I/O on purpose: it has no//! sockets, no clock and no addresses, which is what makes it testable at//! half a million inputs a second and what lets a caller drive it from//! whatever event loop it already has. That is the right shape for the//! library and the wrong shape for somebody who just wants to answer//! requests, because the loop it leaves you to write is not small — a UDP//! socket demultiplexing to many connections, a timer that has to fire while//! the socket is quiet, connection IDs to route by, Retry, stateless reset,//! and a table of all of it.//!//! This module is that loop, written once. It is a separate module rather//! than part of `quic` so that the core keeps its property: nothing in//! `quic` imports anything from here, and a caller who wants the state//! machine alone never compiles a socket.//!//! ## The shape of it//!//! An `Endpoint` owns the socket and the connection table. A `Session` is one//! connection, and a `Stream` is one stream on it, presented as an//! `Io.Reader` and an `Io.Writer` — so the code above looks like code that//! reads and writes, rather than code that pumps.//!//! ```//! Endpoint.pump() one task: socket in, timers, routing//! |//! +-- Session one task each: the application//! |//! +-- Stream Io.Reader / Io.Writer//! ```//!//! ## Who sends//!//! The awkward question in a design like this is how a task that has just//! written to a stream gets its octets onto a socket that another task is//! blocked reading. The usual answers are to poll on a short timeout, or to//! wake the reader with a self-pipe, and both are machinery in service of an//! arrangement nobody asked for.//!//! So neither. **Whatever changes a connection's state flushes that//! connection itself**, under that connection's own lock: the pump flushes//! after a datagram or a timer, and a writing task flushes after it writes.//! A UDP socket takes concurrent sends perfectly well, the lock is per//! connection rather than per endpoint, and there is no wakeup to miss//! because there is nothing waiting to be woken.
const std = @import("std");
pub const Endpoint = @import("Endpoint.zig");/// The end that dials: one connection to one server.pub const Client = @import("Client.zig");pub const Session = @import("Session.zig");pub const Stream = @import("Stream.zig");/// The IP header's ECN field, which §13.4 of RFC 9000 needs and a library/// with no sockets cannot reach. Exposed because it is the seam: a caller/// driving its own socket rather than this `Endpoint` still has to read the/// field and hand it to `Connection.receiveEcn`.pub const ecn = @import("ecn.zig");
test { std.testing.refAllDecls(@This());}