code wiki / _hdl_build / _h2_multistream_curl_daemon.nx
_h2_multistream_curl_daemon.nx
buildroot/runtime/_hdl_build/_h2_multistream_curl_daemon.nx
about
_h2_multistream_curl_daemon.nx -- TUTOR-BOOTSTRAP SCAFFOLD (Claude, authored
under the B1 rung(6) PERSISTENT-MULTI-STREAM external-curl interop step of the
R4-H2 HTTP/2-transport ladder), NOT credited as team self-authoring (back-fill
via the emitter-of-emitters once the daemon-from-spec organ exists).
THE PERSISTENT MULTI-STREAM ALPN-h2 SERVE DAEMON: stands up OUR sovereign
ALPN-h2 TLS 1.3 server on 127.0.0.1:9444 and serves an EXTERNAL, INDEPENDENT h2
client (curl --http2 with libnghttp2/OpenSSL) that issues MULTIPLE same-origin
GETs. Unlike _h2_serve_curl_daemon.nx (which ACCEPTS HCD_N=3 SEPARATE
connections because its single-stream driver GOAWAYs after each request), this
daemon ACCEPTS EXACTLY ONE connection and serves up to MCD_MAX request streams
on it via the persistent driver h2_serve_connection_multi (runtime/
nx_h2_serve_multi.nx). An external curl given K same-origin URLs therefore
REUSES that ONE TCP connection (total num_connects across the K transfers = 1).
MEASURED EXCEED + DISCRIMINATION (the gate):
POS (this daemon, persistent): curl url1 url2 ... urlK on 127.0.0.1:9444 ->
all K transfers HTTP/2 200, TOTAL num_connects = 1 (the connection is
REUSED across streams 1,3,5,...,2K-1).
NEG control (_h2_serve_curl_daemon, single-stream, port 9443): the SAME K
URLs -> each transfer opens a FRESH connection (total num_connects = K),
because the single-stream driver GOAWAYs + closes after each request.
The num_connects measurement DISCRIMINATES persistent multi-stream from
connection-per-request -- it is not a tautology.
FLOW (main):
- mint a self-signed Ed25519 X.509 leaf (SAN=localhost) -- the SAME
sovereign cert path the proven daemon uses (mcd_make_cert).
- EXPORT that DER cert to a PEM file (/tmp/nx_h2_ms_cert.pem) so an external
curl can trust it via --cacert (composes nx_base64 b64_encode).
- socket / SO_REUSEADDR / bind 127.0.0.1:9444 / listen; print
"BOUND 127.0.0.1:9444" so the orchestrator's readiness gate fires.
- ONE accept -> fresh handshake entropy -> h2_serve_connection_multi
(MCD_MAX cap) -> close -> exit 0; the driver returns the COUNT of streams
served (>=1), else an honest negative -> stop-on-RED, no fake-green.
HONEST verdict discipline: this organ's job is to BIND + SERVE >1 external h2
request STREAM on ONE connection. GREEN (server side) iff the handshake
completed and >=2 request streams were parsed + answered :status 200 on the SAME
connection. The EXTERNAL curl judgement ("using HTTP/2" + "Re-using existing
dependencies 9 imports · 0 importers
imports: nx_syscalls.nxnx_h2_serve_multi.nxnx_x25519_ephemeral.nxnx_csprng.nxnx_ed25519_signature.nxnx_x509_build.nxnx_x509.nxnx_x509_trust_store.nxnx_base64.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 72 | const MCD_MAX: i64 = 16 |
| 76 | const MCD_PORT_REAL: i64 = 9444 |
functions
| 80 | func mcd_civil_from_days(days: i64, out_y: *i64, out_m: *i64, out_d: *i64) -> i64 called by 1: mcd_format_generalized_time |
| 96 | func mcd_format_generalized_time(unix_sec: i64, out_15: *u8) -> i64 |
| 126 | func mcd_addr(out: *u8, port: i64) -> i64 called by 1: main |
| 137 | func mcd_make_cert(out_cert_der: *u8, out_cert_len: *i64, out_priv: *u8) -> i64 |
| 162 | func mcd_write_pem(cert_der: *u8, der_len: i64, path_z: *u8) -> i64 |
| 186 | func mcd_log(verdict_green: i64, served_or_code: i64) -> i64 |
| 209 | func main() -> i64 |