nx_websocket_stream.nx
buildroot/runtime/nx_websocket_stream.nx
about
nx_websocket_stream.nx -- streaming WebSocket framer over a TCP fd.
The missing piece between nx_websocket_frame (parse one frame from
a buffer) and a real per-connection daemon loop. Reads bytes from
the socket handling partial reads + assembles a complete frame
(header + payload), then unmasks the payload in place per RFC 6455
ยง5.3 (client-to-server frames MUST be masked).
Composes:
nx_websocket_frame.ws_parse_frame -- header decode
nx_websocket_frame.ws_apply_mask -- in-place unmask
nx_websocket_frame.ws_build_header -- server-to-client frame build
sys_read / sys_write -- I/O
Per Cardinals 9 (single-responsibility: ONE frame per call), 12
(defensive at boundary: bounds checks on payload_len + out_cap),
22 (composition of shipped primitives, no inline frame parsing).
Caller responsibilities:
- allocate out_buf with cap >= max expected frame (header + payload)
- check returned verdict before using out_frame fields
- for incoming client frames, payload is unmasked in place
genealogy_id: rfc_6455 + nx_websocket_frame + nx_tls13_read_record_from_fd_q10
lineage_id: nishi_websocket_stream_q1
dependencies 2 imports · 6 importers
imports: nx_syscalls.nxnx_websocket_frame.nx
imported by: nx_friend_video_caller.nxnx_health_eval.nxnx_sig2_bp_gate.nxnx_signaling_v2.nxnx_signaling_v2_gate.nxnx_websocket_stream_test.nx
structs
| none |
consts
| 30 | const NX_WSS_OK: i64 = 1 |
| 31 | const NX_WSS_READ_FAIL: i64 = 2 |
| 32 | const NX_WSS_EOF: i64 = 3 |
| 33 | const NX_WSS_FRAME_TOO_BIG: i64 = 4 |
| 34 | const NX_WSS_PARSE_FAIL: i64 = 5 |
| 35 | const NX_WSS_WRITE_FAIL: i64 = 6 |
| 36 | const NX_WSS_VERDICT_N: i64 = 7 |
functions
| 38 | func nx_wss_verdict_is_valid(v: i64) -> i64 |
| 47 | func _wss_read_n(fd: i64, buf: *u8, off: i64, want: i64) -> i64 |
| 63 | func _wss_write_n(fd: i64, buf: *u8, n: i64) -> i64 |
| 86 | func nx_ws_read_frame_from_fd(fd: i64, |
| 148 | func nx_ws_send_frame_to_fd(fd: i64, |
| 166 | func nx_ws_send_text(fd: i64, text: *u8, text_len: i64) -> i64 |
| 171 | func nx_ws_send_pong(fd: i64, payload: *u8, payload_len: i64) -> i64 |
| 177 | func nx_ws_send_close(fd: i64, code: i64) -> i64 |
| 187 | func main() -> i64 |