March Docs › NetKernel NetKernel NetKernel: the socket-level transport for distributed OTP (P1).
Bridges the pure protocol layer (NetFrame / NodeIdentity / ClusterAuth / Handshake, all over List(Int) bytes) to real TCP sockets (Socket, over String). It frames messages, reads complete frames off a byte stream (partial-read safe), and runs the authenticated handshake that gates a peer into the cluster.
The pure bridge (to_wire / str_to_bytes / bytes_to_str) is unit-tested; the socket handshake is runtime-exercised (sockets/scheduler are not run by the eval-based stdlib test harness, matching ChannelServer's convention).
P5 frame types (tag byte prepended before the msgpack payload): 0x05 REGISTRY_SYNC_REQ [tag=5, root_hash:Str] 0x06 REGISTRY_SYNC_RESP [tag=6, root_hash:Str, leaves:[[name,nid,pid,clock_json,present],...]] 0x07 MONITOR_REQ [tag=7, watcher_node:Str, watcher_pid:Int, target_pid:Int] 0x08 MONITOR_FIRE [tag=8, target_pid:Int, reason_tag:Int, reason_msg:Str] reason_tag: 0=Normal, 1=Killed, 2=Crash, 3=NodeDown
Functions fn bytes_to_str bytes_to_str(b : List(Int)) : String do Bytes.to_string(Bytes.from_list(b)) end #
fn decode_monitor_fire decode_monitor_fire(bytes : List(Int)) : Result((Int, Int, String), String) #
fn decode_monitor_req decode_monitor_req(bytes : List(Int)) : Result((String, Int, Int), String) #
fn decode_registry_sync_req decode_registry_sync_req(bytes : List(Int)) : Result(String, String) #
fn decode_registry_sync_resp decode_registry_sync_resp(bytes : List(Int)) : Result((String, List((String, GlobalRegistry.Entry))), String) #
fn encode_monitor_fire encode_monitor_fire(target_pid : Int, reason_tag : Int, reason_msg : String) : List(Int) #
fn encode_monitor_req encode_monitor_req(watcher_node : String, watcher_pid : Int, target_pid : Int) : List(Int) #
fn encode_registry_sync_req encode_registry_sync_req(root_hash : String) : List(Int) #
fn encode_registry_sync_resp encode_registry_sync_resp(root_hash : String, #
fn frame_tag frame_tag(bytes : List(Int)) : Option(Int) #
fn fresh_nonce fresh_nonce() : String do Crypto.random_hex(16) end #
fn handshake handshake(fd : Int, my_id : NodeIdentity.Identity, secret : String, #
fn recv_frame recv_frame(fd : Int, buf : List(Int)) : Result((List(Int), List(Int)), String) #
fn send_frame send_frame(fd : Int, payload : List(Int)) : Result((), String) #
fn str_to_bytes str_to_bytes(s : String) : List(Int) do Bytes.to_list(Bytes.from_string(s)) end #
fn to_wire to_wire(payload : List(Int)) : String #