| module | STDNET | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| tag | v0.8.0 | ||||||||
| phase | M2 — VSL/MSL S4 socket seam | ||||||||
| stable | stable | ||||||||
| since | v0.8.0 | ||||||||
| synopsis | portable raw-TCP socket primitives (engine-native sockets) | ||||||||
| labels |
|
||||||||
| errors | |||||||||
| conformance | |||||||||
| see_also |
|
STDNET is the portable socket seam (S4 of the MSL⟷VSL coordination plan):
a thin, handle-based, raw-byte TCP API that any pure-M service can use on a
bare engine, and that the VistA VSLIO adapter binds to VistA's device handler
(^%ZIS / CALL^%ZISTCP) above the m/v waterline. It drives each engine's
native socket device — no C call-outs — with the (large) engine divergence
isolated behind $ZVERSION["IRIS" arms.
@tier optional — engine-sensitive and, today, YottaDB-only.
All transfers are raw bytes: no record delimiter, no packet framing. Handles are
small integers; per-handle state (device name, accepted-socket name, bound port)
lives in the process-private ^STDLIB($job,"stdnet",id,*).
| Call | Purpose |
|---|---|
$$available^STDNET() |
1 iff raw sockets are wired on this engine |
$$listen^STDNET(port) |
open a listening socket (0 ⇒ OS-assigned port) → handle, or 0 |
$$boundport^STDNET(id) |
the actual bound port of a listener handle |
$$accept^STDNET(id,timeout) |
accept a pending connection → connection handle, or 0 |
$$connect^STDNET(host,port,timeout) |
client connect → handle, or 0 |
$$read^STDNET(id,maxlen,timeout,.buf) |
raw-read up to maxlen bytes → count, buf by-ref |
$$write^STDNET(id,buf) |
raw-write buf → 1/0 |
$$close^STDNET(id) |
close a handle (idempotent) → 1 |
set srv=$$listen^STDNET(0) ; OS-assigned port
set port=$$boundport^STDNET(srv)
set cli=$$connect^STDNET("127.0.0.1",port,5)
set conn=$$accept^STDNET(srv,5) ; the server-side connection
if $$write^STDNET(cli,"ping")
set n=$$read^STDNET(conn,99,5,.buf) ; buf="ping"
if $$write^STDNET(conn,buf) ; echo back
set n=$$read^STDNET(cli,99,5,.buf) ; buf="ping"
set n=$$close^STDNET(cli),n=$$close^STDNET(conn),n=$$close^STDNET(srv)
- YottaDB — implemented. YottaDB's
SOCKETdevice is a collection of sockets per device, so a single process canlisten+connect+accept(the loopback the suite uses).acceptisWRITE /WAIT, which auto-accepts the connection — the new socket handle is$PIECE($KEY,"|",2)(there is no separate/ACCEPT; that raisesLOCALSOCKREQ). Each verb saves/restores$IOso it never disturbs the caller's current device. - IRIS — not yet wired:
$$available^STDNET()returns0, every verb returns its safe-failure value, andSTDNETTSTsoft-skips green (the same posture asSTDHTTP's libcurl soft-fail). The IRIS leg (the|TCP|device + aJOB'd connector for loopback, since IRIS has no collection-of-sockets device) is the owed follow-up, to be live-verified onm-test-iris.
The side-effecting verbs (listen/accept/connect/read/write/close)
carry ; doc: @seam STDNET → the seams.STDNET block of dist/stdlib-manifest.json
(+ dist/seam-snapshot.json). VSLIO (v-stdlib, M2) pins this contract and
implements the same signatures over ^%ZIS/CALL^%ZISTCP + named TLS.