lumbda/tests
russell@unturf.com bfd4ec7ec8 sockets + portable HTTP server — 6 primitives, same server runs in all 3
Added tcp-listen/accept/connect/recv/send/close to Python, C, and asm.
One examples/http-server.lsp runs identically in all three impls and
serves HTTP/1.0 with routing, content-type, and content-length headers.

asm additions:
- SYS_SOCKET/BIND/LISTEN/ACCEPT/CONNECT/SETSOCKOPT syscalls
- 6 tcp-* builtins using the existing port encoding (SPECIAL ≥ 1000)
- bi_tcp_connect: dotted-quad IPv4 parser, no DNS dependency

Defects fixed along the way (surfaced by the HTTP server):
- string-append: was 2-arg only; now variadic (walks arg list twice)
- number->string: was stubbed to VAL_VOID; now correctly writes digits
  into a heap-allocated string (incl. negative handling)
- String-literal reader: \r and \0 escape sequences now handled (was
  silently dropping backslash, treating them as literal 'r' / '0')
- tcp_accept: sockaddr buffer was 8 bytes, now 16 (was corrupting
  caller's stack when accept wrote full struct sockaddr_in)

Pinocchio benchmark (tests/web-benchmark.sh):
At concurrency=20, 1000 requests, serving a 1KB body:

  uncommonlisp Python   373 req/s
  uncommonlisp C        370 req/s
  uncommonlisp asm      370 req/s
  python3 http.server   381 req/s  (stdlib reference)
  busybox httpd         382 req/s  (production reference)

All five converge within 3% — the client (curl fork/exec) is the
bottleneck, not the server. Our single-threaded blocking servers
are indistinguishable from battle-tested ones at this load.

Binary sizes:
  uncommonlisp asm    45 KB   (HTTP + everything else)
  busybox httpd       2.1 MB  (multi-call binary)
  python3             8 MB    (interpreter)

The asm HTTP server is 46× smaller than busybox and 176× smaller
than Python, serves from 7 Linux syscalls, and the entire protocol
handler is 70 lines of portable Scheme.

Test counts: 132 asm (up 1), rest unchanged. All green.
2026-04-16 18:58:27 -04:00
..
functional.lsp asm/c/py: add (load), ports, write-file/file->string — full cross-impl parity 2026-04-16 16:37:40 -04:00
portal-benchmark.sh portal benchmark + 3 mismatch defects fixed 2026-04-16 16:57:24 -04:00
portal-cross-load.lsp asm/c/py: add (load), ports, write-file/file->string — full cross-impl parity 2026-04-16 16:37:40 -04:00
portal-cross-save.lsp asm/c/py: add (load), ports, write-file/file->string — full cross-impl parity 2026-04-16 16:37:40 -04:00
portal-cross-test.sh asm/c/py: add (load), ports, write-file/file->string — full cross-impl parity 2026-04-16 16:37:40 -04:00
portal-exchange.lsp asm/c/py: add (load), ports, write-file/file->string — full cross-impl parity 2026-04-16 16:37:40 -04:00
portal-formats.lsp asm/c/py: add (load), ports, write-file/file->string — full cross-impl parity 2026-04-16 16:37:40 -04:00
web-benchmark.sh sockets + portable HTTP server — 6 primitives, same server runs in all 3 2026-04-16 18:58:27 -04:00