skip to content
==> README.md <==
1# @ajax/mesh-peer-link
2
3The fleet's TCP links: `mpn_connect` (bounded in time: a dead peer would otherwise take minutes of SYN
4retries), `mpn_handshake` (F_JOIN both ways, checked), `mpn_listen`, an acceptor (each lower system's
5link handshaken on its own thread) and dialers (redialing with a 100 ms .. 1 s backoff once their link
6dies, refusals logged once). A link (`mpn_link_start`) has a reader thread that reads whole frames by
7type, refusing any hostile length before it reads it (`mpn_read_frame`: exactly peer.rs's reader
8rules), and a writer thread that sends every queued control frame before each bulk frame, so a blob in
9flight delays a beat by one frame at most. The lockstep rounds write directly under the writer lock
10(`mpn_write_now`).
11
12The owner gets frames and the close on the link's reader thread (`mpn_sink`); it must not free the link
13from that callback (queue it to its own thread).
14
15## Ported from
16
17[alpha-rust-mesh](https://github.com/rsafier/alpha-rust-mesh) `crates/mesh-host/src/peer.rs`:
18`connect`, `handshake`, `acceptor`, `dialer`, `Link`, `reader` (its framing; the decoding is the
19relay's), `writer`, `LINK_QUEUE`, `BULK_QUEUE`.
20
21## Tests
22
23`tests/link.c`: the Rust's `handshake_over_tcp`, every frame type read back through the framer, hostile
24lengths refused, and a link's frames both ways with its close.
25
26## Licence
27
28MIT. See the repository's LICENSE.