TsgcQUICServer › Methods › Start

Start Method

Loads OpenSSL, creates the QUIC listener and begins accepting incoming connections.

Syntax

procedure Start;

Remarks

Start performs the full server bring-up: it validates that QUICOptions.SSLOptions.CertFile and KeyFile are set, loads the OpenSSL library, creates the SSL context, registers the ALPN selection callback (QUIC mandates ALPN, the callback prefers h3 and otherwise takes the peer's first offer), builds the QUIC listener bound to Port over UDP, and launches a background thread that drives the QUIC event loop: accepting connections, advancing handshakes and reading stream data. After it returns, OnQUICConnect fires for each accepted connection.

An exception is raised when the certificate or private key is missing or cannot be loaded, when the key does not match the certificate, when the UDP port cannot be bound, when Host cannot be resolved, or when the installed OpenSSL is older than 3.5 (the version that introduced the SSL_new_listener QUIC server API). Wrap the call in a try..except, the misconfiguration cases all surface here. Start runs on the caller's thread and raises directly, so these exceptions do not reach OnQUICException.

The listener binds the address in Host. A value holding a colon is an IPv6 literal, and any other value, an IPv4 literal or a host name, is resolved over both families. An empty Host binds the dual-stack IPv6 wildcard, which accepts IPv4 and IPv6 peers alike, and falls back to 0.0.0.0 only on a machine with no IPv6 stack. Start is implemented as Active := True, so the two are interchangeable, Active reports True after a successful start, and calling Start on an already started server does nothing. Once the listener is bound and the event loop is running, OnStartup is raised, before Start returns.

Example


oServer.Port := 4433;
oServer.QUICOptions.SSLOptions.CertFile := 'cert.pem';
oServer.QUICOptions.SSLOptions.KeyFile := 'key.pem';
oServer.Start;

Back to Methods