nx_socket_pingpong_test.nx
buildroot/runtime/nx_socket_pingpong_test.nx
about
nx_socket_pingpong_test.nx -- prove TCP listen/accept/connect
loopback works via real Linux syscalls. Foundation for L9
distributed MIMD (nx_net_chan, nx_remote_spawn, nx_rpc).
Design: parent thread is the SERVER (listens + accepts + echoes
"ping" -> "pong" once + closes); a spawned child thread is the
CLIENT (sleeps briefly to let parent bind, then connects + sends
"ping" + receives "pong" + closes + sets done flag). Main spin-
waits on the done flag.
Uses port NX_PORT (chosen high to avoid privileged + commonly-used);
if port is already in use the bind() returns -EADDRINUSE which we
surface as a clear failure code rather than hanging.
dependencies 5 imports · 0 importers
imports: nx_kernel_v2.nxnx_log.nxnx_atom.nxnx_thread.nxnx_socket.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| 24 | struct PingPongState |
consts
| 21 | const NX_PORT: i64 = 38917 // arbitrary high port |
functions
| 29 | func _sleep_ms(ms: i64) -> i64 called by 1: client_main |
| 38 | func client_main(arg: *u8) -> i64 |
| 80 | func main() -> nx_exit |