Expand description
TCP client natives (tcp.lg): the SYNC implementations the AOT tier calls via
map_native_function, plus the shared error-message formatters every tier
reuses — one wording, so the tiers cannot drift even in their Err text.
Std-only (no tokio): the AOT tier blocks the calling thread, exactly like
file::read. The async tiers (tree-walker/VM) live in the compile crate’s
TcpRegistry over tokio and reuse the formatters below.
Connections are process-global, keyed by an opaque Int handle — the value a
LOGOS program threads through tcpSend/tcpRecv/tcpClose. A closed or
never-opened handle is always an Err value, never a panic.
Constants§
- MAX_
RECV - The largest single
tcpRecv/tcpRecvExactrequest (64 MiB) — a guard against a hostile or corrupted length field, not a protocol limit (loop for more).
Functions§
- accept
- Accept one queued connection (blocks; a
set_timeouton the listener applies). - close
- Close the connection or listener; the handle is dead afterwards.
- connect
- Open a TCP connection;
Okcarries the opaque connection handle. - connect_
tls - Open a TCP connection and complete a TLS handshake over it;
Okcarries the same opaque handle every other native takes, sotcpSend/tcpRecvwork unchanged. - ensure_
crypto_ provider - The client TLS configuration: the bundled Mozilla roots, plus any extra root the operator
names in
LOGOS_TLS_EXTRA_ROOT(a PEM file). - err_
accept - err_
connect - err_
invalid_ len - err_
invalid_ port - err_
invalid_ timeout - err_
listen - err_
recv - err_
send - err_
shutdown - err_
timeout - err_
torn - err_
unknown_ conn - listen
- Bind a listening socket (passive open; port
0= ephemeral). - listener_
port - The local port a listener is bound to (how an ephemeral bind is learned).
- recv
- Block until at least one byte arrives (or EOF), returning up to
max_lenbytes. A clean EOF isOkof the empty Seq — a value, not an error. - recv_
exact - Block until exactly
lenbytes arrive; a peer closing early is anErr(a torn frame is never silently truncated — protocol framing depends on it). - send
- Send every byte (each Int masked to 0–255);
Okcarries the byte count.dataarrives as the AOT tier’s borrowedSeq of Intparameter form. - set_
timeout - Set the connection’s read+write timeout in milliseconds (
0clears it) — Pythonsettimeoutstyle: it applies to every subsequent recv/send, whose expiry is the sharedtcp: operation timed outerror. - shutdown_
write - Half-close: send FIN on the write side (
shutdown(SHUT_WR)), keep reading. - tls_
config - upgrade_
tls - Wrap an ESTABLISHED plain connection in TLS, in place.