nx_net_chan.nx
buildroot/runtime/nx_net_chan.nx
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
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
structs
| 37 | struct NxNetChan |
consts
| 35 | const NX_MAGIC_9223372036854775807: i64 = 9223372036854775807 |
| 42 | const NX_NET_CHAN_BYTES: i64 = 16 |
| 122 | const NX_NET_BLOB_MAX_LEN: i64 = 1073741824 // 1 GiB safety ceiling |
functions
| 45 | func _nx_net_pack_be64(buf: *u8, v: i64) -> i64 |
| 58 | func _nx_net_unpack_be64(buf: *u8) -> i64 |
| 74 | func nx_net_chan_from_fd(fd: i64) -> *NxNetChan |
| 84 | func nx_net_chan_send(c: *NxNetChan, v: i64) -> i64 |
| 101 | func nx_net_chan_recv(c: *NxNetChan, out: *i64) -> i64 |
| 124 | func _nx_net_write_n(fd: i64, buf: *u8, n: i64) -> i64 called by 1: nx_net_chan_send_blob |
| 135 | func _nx_net_read_n(fd: i64, buf: *u8, n: i64) -> i64 called by 1: nx_net_chan_recv_blob |
| 148 | func nx_net_chan_send_blob(c: *NxNetChan, buf: *u8, n: i64) -> i64 called by 4: client_mainmainnx_rpc_server_runnx_rpc_call calls 3: sys_mmap_nx_net_pack_be64_nx_net_write_n |
| 165 | func nx_net_chan_recv_blob(c: *NxNetChan, buf: *u8, max_len: i64) -> i64 called by 4: client_mainmainnx_rpc_server_runnx_rpc_call calls 3: sys_mmap_nx_net_read_n_nx_net_unpack_be64 |
| 180 | func nx_net_chan_close(c: *NxNetChan) -> i64 called by 8: client_mainmainclient_mainmain_nx_remote_worker_mainnx_remote_shutdown+2 calls 2: nx_sock_shutdownsys_close |
| 189 | func main() -> i64 |