Skip to main content

Module server

Module server 

Source
Expand description

The listeners and connection loops.

Server::setup binds the listener (and, in the http1 build, creates the thread pool); then Server::run (http1), run_tls (TLS with HTTP/2 via ALPN, or plain HTTP/1.1 without a certificate), run_quic (HTTP/3) and run_redirect (HTTP → HTTPS) accept connections, parse requests and hand them to your Application. ConnectionInfo carries the client and server addresses and the TLS SNI name. Examples: src/server/example/.

Modules§

per_core
Per-core runtimes (RWS_CONFIG_RUNTIME=per-core, Unix only): one single-threaded tokio runtime per core, each accepting on its own SO_REUSEPORT socket, the way nginx runs one worker per core. A connection stays on the thread the kernel gave it to, so there’s no work stealing, no cross-thread wake-ups and no idle workers searching for work.

Structs§

Address
IP address and port pair.
ConnectionInfo
Network context for the current connection, passed into every Controller.
Server

Constants§

REQUEST_HEAD_TIMEOUT
Longest time from the first byte of a request head to its end (nginx’s client_header_timeout). The idle timeout alone restarts on every read, so a client sending one byte every few seconds could hold a connection for weeks with a 64 KiB head.