code wiki / (root) / nx_net.nx

nx_net.nx

buildroot/runtime/nx_net.nx

9395 B268 linesdepth 2pulls 3 transitivereach 0 importersview sourcekind orphan librarytopic net
docsdependenciesstructsconstsfunctions

about

net.nx -- BSD-style socket primitives (Phase G2). Typed wrappers around Linux/NishiOS socket syscalls. Fallible public calls return `*Result<i64, NetError>` -- the Ok payload is an fd (for socket / accept) or a byte count (for send / recv) or 0 (for bind / listen / connect). Raw `_raw` variants keep the bare syscall return for callers that want the i64 directly (e.g. tight send loops). Syscall numbers (Linux RV64, NishiOS matches): 198 socket 200 bind 201 listen 202 accept 203 connect 206 sendto (we use as send) 207 recvfrom (we use as recv) 208 setsockopt 209 getsockopt Address families (SOL): AF_INET = 2 (IPv4) AF_INET6 = 10 (IPv6) Socket types: SOCK_STREAM = 1 (TCP) SOCK_DGRAM = 2 (UDP) The typed variant struct SockAddrIn matches Linux's `struct sockaddr_in` exactly (16 bytes): sin_family + sin_port (big- endian) + sin_addr + 8 bytes of padding.

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_stdlib.nx nx_net.nx

imports: nx_syscalls.nxnx_stdlib.nx

imported by: nobody (leaf or entry point)

structs

59struct SockAddrIn

consts

42const SYS_SOCKET: i64 = 198
43const SYS_BIND: i64 = 200
44const SYS_LISTEN: i64 = 201
45const SYS_ACCEPT: i64 = 202
46const SYS_CONNECT: i64 = 203
47const SYS_SENDTO: i64 = 206
48const SYS_RECVFROM: i64 = 207
49const SYS_SETSOCKOPT: i64 = 208
51const AF_INET: i64 = 2
52const SOCK_STREAM: i64 = 1
53const SOCK_DGRAM: i64 = 2
256const SOL_SOCKET: i64 = 1
257const SO_REUSEADDR: i64 = 2
258const SO_REUSEPORT: i64 = 15

functions

83func net_errno_to(e: i64) -> i64
100func net_tcp_raw() -> i64
called by 1: net_tcp
104func net_udp_raw() -> i64
called by 1: net_udp
109func net_tcp() -> *Result<i64, NetError>
115func net_udp() -> *Result<i64, NetError>
123func net_close(fd: i64) -> *Result<i64, NetError>
133func net_addr_any(sa: *SockAddrIn, port: i64) -> i64
150func net_addr(sa: *SockAddrIn, port: i64, ip: i64) -> i64
163func net_bind_raw(fd: i64, sa: *SockAddrIn) -> i64
called by 1: net_bind
167func net_bind(fd: i64, sa: *SockAddrIn) -> *Result<i64, NetError>
175func net_listen_raw(fd: i64, backlog: i64) -> i64
called by 1: net_listen
179func net_listen(fd: i64, backlog: i64) -> *Result<i64, NetError>
189func net_accept_raw(fd: i64, peer: *SockAddrIn,
called by 1: net_accept
195func net_accept(fd: i64, peer: *SockAddrIn,
205func net_connect_raw(fd: i64, sa: *SockAddrIn) -> i64
called by 1: net_connect
209func net_connect(fd: i64, sa: *SockAddrIn) -> *Result<i64, NetError>
225func net_send(fd: i64, buf: *u8, n: i64) -> i64
called by 1: net_send_all_raw
231func net_recv(fd: i64, buf: *u8, n: i64) -> i64
236func net_send_all_raw(fd: i64, buf: *u8, n: i64) -> i64
called by 1: net_send_all calls 1: net_send
248func net_send_all(fd: i64, buf: *u8, n: i64) -> *Result<i64, NetError>
262func net_set_reuseaddr(fd: i64) -> i64
calls 1: sys_mmap