code wiki / (root) / nx_socket_pingpong_test.nx

nx_socket_pingpong_test.nx

buildroot/runtime/nx_socket_pingpong_test.nx

5943 B142 linesdepth 6pulls 12 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

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

nx_kernel_v2.nx nx_log.nx nx_atom.nx nx_thread.nx nx_socket.nx nx_socket_pingpong_test.nx

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

main nx_sock_socket nx_sock_reuseaddr nx_sock_setsockopt nx_sock_sin_init nx_sock_htons nx_sock_bind nx_sock_listen nx_thread_spawn_fn sys_mmap nx_sock_accept nx_sock_shutdown nx_atom_load_i64 nx_thread_yield

structs

24struct PingPongState

consts

21const NX_PORT: i64 = 38917 // arbitrary high port

functions

29func _sleep_ms(ms: i64) -> i64
called by 1: client_main
38func client_main(arg: *u8) -> i64
80func main() -> nx_exit