code wiki / (root) / nx_websocket_stream.nx

nx_websocket_stream.nx

buildroot/runtime/nx_websocket_stream.nx

7018 B189 linesdepth 3pulls 3 transitivereach 7 importersview sourcekind tooltopic websocket
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_websocket_frame.nx nx_websocket_stream.nx nx_friend_video_caller.nx nx_health_eval.nx nx_sig2_bp_gate.nx nx_signaling_v2.nx nx_signaling_v2_gate.nx nx_websocket_stream_test.nx

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

30const NX_WSS_OK: i64 = 1
31const NX_WSS_READ_FAIL: i64 = 2
32const NX_WSS_EOF: i64 = 3
33const NX_WSS_FRAME_TOO_BIG: i64 = 4
34const NX_WSS_PARSE_FAIL: i64 = 5
35const NX_WSS_WRITE_FAIL: i64 = 6
36const NX_WSS_VERDICT_N: i64 = 7

functions

38func nx_wss_verdict_is_valid(v: i64) -> i64
47func _wss_read_n(fd: i64, buf: *u8, off: i64, want: i64) -> i64
called by 1: nx_ws_read_frame_from_fd calls 1: sys_read
63func _wss_write_n(fd: i64, buf: *u8, n: i64) -> i64
called by 1: nx_ws_send_frame_to_fd calls 1: sys_write
86func nx_ws_read_frame_from_fd(fd: i64,
148func nx_ws_send_frame_to_fd(fd: i64,
166func nx_ws_send_text(fd: i64, text: *u8, text_len: i64) -> i64
171func nx_ws_send_pong(fd: i64, payload: *u8, payload_len: i64) -> i64
177func nx_ws_send_close(fd: i64, code: i64) -> i64
187func main() -> i64