nx_net.nx
buildroot/runtime/nx_net.nx
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
imports: nx_syscalls.nxnx_stdlib.nx
imported by: nobody (leaf or entry point)
structs
| 59 | struct SockAddrIn |
consts
| 42 | const SYS_SOCKET: i64 = 198 |
| 43 | const SYS_BIND: i64 = 200 |
| 44 | const SYS_LISTEN: i64 = 201 |
| 45 | const SYS_ACCEPT: i64 = 202 |
| 46 | const SYS_CONNECT: i64 = 203 |
| 47 | const SYS_SENDTO: i64 = 206 |
| 48 | const SYS_RECVFROM: i64 = 207 |
| 49 | const SYS_SETSOCKOPT: i64 = 208 |
| 51 | const AF_INET: i64 = 2 |
| 52 | const SOCK_STREAM: i64 = 1 |
| 53 | const SOCK_DGRAM: i64 = 2 |
| 256 | const SOL_SOCKET: i64 = 1 |
| 257 | const SO_REUSEADDR: i64 = 2 |
| 258 | const SO_REUSEPORT: i64 = 15 |
functions
| 83 | func net_errno_to(e: i64) -> i64 |
| 100 | func net_tcp_raw() -> i64 called by 1: net_tcp |
| 104 | func net_udp_raw() -> i64 called by 1: net_udp |
| 109 | func net_tcp() -> *Result<i64, NetError> |
| 115 | func net_udp() -> *Result<i64, NetError> |
| 123 | func net_close(fd: i64) -> *Result<i64, NetError> |
| 133 | func net_addr_any(sa: *SockAddrIn, port: i64) -> i64 |
| 150 | func net_addr(sa: *SockAddrIn, port: i64, ip: i64) -> i64 |
| 163 | func net_bind_raw(fd: i64, sa: *SockAddrIn) -> i64 called by 1: net_bind |
| 167 | func net_bind(fd: i64, sa: *SockAddrIn) -> *Result<i64, NetError> |
| 175 | func net_listen_raw(fd: i64, backlog: i64) -> i64 called by 1: net_listen |
| 179 | func net_listen(fd: i64, backlog: i64) -> *Result<i64, NetError> |
| 189 | func net_accept_raw(fd: i64, peer: *SockAddrIn, called by 1: net_accept |
| 195 | func net_accept(fd: i64, peer: *SockAddrIn, |
| 205 | func net_connect_raw(fd: i64, sa: *SockAddrIn) -> i64 called by 1: net_connect |
| 209 | func net_connect(fd: i64, sa: *SockAddrIn) -> *Result<i64, NetError> |
| 225 | func net_send(fd: i64, buf: *u8, n: i64) -> i64 called by 1: net_send_all_raw |
| 231 | func net_recv(fd: i64, buf: *u8, n: i64) -> i64 |
| 236 | func net_send_all_raw(fd: i64, buf: *u8, n: i64) -> i64 |
| 248 | func net_send_all(fd: i64, buf: *u8, n: i64) -> *Result<i64, NetError> |
| 262 | func net_set_reuseaddr(fd: i64) -> i64 calls 1: sys_mmap |