code wiki / (root) / nx_net_chan.nx

nx_net_chan.nx

buildroot/runtime/nx_net_chan.nx

7586 B213 linesdepth 4pulls 5 transitivereach 7 importersview sourcekind tooltopic net
docsdependenciesstructsconstsfunctions

about

nx_net_chan.nx -- typed i64 channel serialised over TCP. Same send/recv semantics as nx_chan (Vyukov MPMC), but the "channel" is a connected TCP socket and each message is 8 bytes big-endian on the wire. Composes with nx_thread_pool / nx_parallel transparently -- a NetChan is a 64-bit handle (the socket fd) that workers can send to or receive from. Wire format: - Each message is a fixed 8-byte big-endian i64 frame. - No length prefix, no checksum, no framing markers. TCP is stream-oriented but with fixed-size frames the receiver can always read exactly 8 bytes per message. - For variable-length payloads (typed structs, byte arrays), use nx_net_chan_blob (queued; length-prefix framed). Endianness: big-endian on the wire (network byte order convention) even though both host and target are likely little-endian. Makes cross-architecture wire compatibility trivial when the cluster becomes heterogeneous. Composes against: [[nx_socket_tcp_loopback]] (transport), [[atomic_intrinsics_real_amo]] (if multiple workers share a NetChan, the underlying socket is the synchronisation point -- kernel handles the lock).

dependencies 3 imports · 7 importers

nx_syscalls.nx nx_atom.nx nx_socket.nx nx_net_chan.nx nx_net_chan_blob_test.nx nx_net_chan_test.nx nx_netsync_gate.nx nx_remote_worker.nx nx_remote_worker_test.nx nx_rpc.nx nx_rpc_test.nx

imports: nx_syscalls.nxnx_atom.nxnx_socket.nx

imported by: nx_net_chan_blob_test.nxnx_net_chan_test.nxnx_netsync_gate.nxnx_remote_worker.nxnx_remote_worker_test.nxnx_rpc.nxnx_rpc_test.nx

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap _nx_net_pack_be64 _nx_net_unpack_be64

structs

37struct NxNetChan

consts

35const NX_MAGIC_9223372036854775807: i64 = 9223372036854775807
42const NX_NET_CHAN_BYTES: i64 = 16
122const NX_NET_BLOB_MAX_LEN: i64 = 1073741824 // 1 GiB safety ceiling

functions

45func _nx_net_pack_be64(buf: *u8, v: i64) -> i64
58func _nx_net_unpack_be64(buf: *u8) -> i64
74func nx_net_chan_from_fd(fd: i64) -> *NxNetChan
84func nx_net_chan_send(c: *NxNetChan, v: i64) -> i64
101func nx_net_chan_recv(c: *NxNetChan, out: *i64) -> i64
124func _nx_net_write_n(fd: i64, buf: *u8, n: i64) -> i64
135func _nx_net_read_n(fd: i64, buf: *u8, n: i64) -> i64
148func nx_net_chan_send_blob(c: *NxNetChan, buf: *u8, n: i64) -> i64
165func nx_net_chan_recv_blob(c: *NxNetChan, buf: *u8, max_len: i64) -> i64
180func nx_net_chan_close(c: *NxNetChan) -> i64
189func main() -> i64