Server flags
The same server can run single-threaded, on several threads, on several
processes, or on AF_XDP. wired_srvdriver_parse reads that choice from the
command line. This page runs two worker threads (--cores 0,1, one per
CPU) and takes three TLS handshakes.
Code
#define WIRED_MAIN#include "wired.h"
/* Unused here: the client below only does TLS handshakes, no requests. */static int on_request( void* ctx, const wired_h3reqdrive_req* req, u64 offset, wired_obuf* body_out, const char** content_type, int* more, u64* total_size) { (void)ctx; (void)req; (void)offset; (void)body_out; (void)content_type; (void)more; (void)total_size; return 0;}
int wired_main(int argc, char** argv) { /* The same fixed demo identity as the HTTP/3 hello page. */ static wired_srvboot_demo_keys keys; wired_srvboot_id id; wired_srvboot_demo(&id, &keys, 0x50, "guide-h3");
/* --port, --workers, --cores, --ifindex, ... pick and configure a driver. */ wired_srvdriver_opt opt = {0}; if (!wired_srvdriver_parse(argc, argv, &opt)) { wired_log_str("bad flags\n"); return 2; } wired_srvrun_handler h = {.cb = on_request}; wired_srvrun_obs obs = {0}; return wired_srvdriver_run(&id, h, obs, &opt) < 0 ? 1 : 0;}Output
$ ./quic-server-flags --port 4433 --cores 0,1conn closed by peer (CONNECTION_CLOSE)conn closed by peer (CONNECTION_CLOSE)conn closed by peer (CONNECTION_CLOSE)$ probe tls 127.0.0.1:4433 3handshake 1 ok: TLS 1.3handshake 2 ok: TLS 1.3handshake 3 ok: TLS 1.3How it works
Section titled “How it works”wired_srvdriver_parse(argc, argv, &opt)reads--port,--workers,--cores,--ifindex,--pin-coreand related flags intowired_srvdriver_opt. It returns 0 for a bad value or a conflicting combination, such as--workerswith--cores.wired_srvdriver_run(&id, h, obs, &opt)starts the driveropt.kindnames: a single process,--workers Nforked processes,--cores 0,1(one thread per listed CPU), or--ifindexAF_XDP.- The identity and handler are the same as in the HTTP/3 hello page.