skip to content
[readonly]

The fleet's TCP links: bounded connects, the JOIN handshake both ways, the acceptor and dialers, a framed reader that refuses hostile lengths, and a writer that puts control frames before bulk ones

sh
$ sexc add @ajax/mesh-peer-link
  • total 3
  • drwxr-xr-x-../
  • drwxr-xr-x-Oct 27 04:09v/# 1 version
  • drwxr-xr-x-Oct 27 04:09files/# the files of 0.1.0
latest
0.1.0, published Oct 27 04:09 by ajax
owners
ajax
license
MIT
dependencies
@ajax/mesh-check ^0.1.0, @ajax/mesh-mt ^0.1.0, @ajax/mesh-peer-codec ^0.1.0, @ajax/mesh-place-wire ^0.1.0, @ajax/mesh-abi-base ^0.1.0, @ajax/mesh-abi-peer-frames ^0.1.0, @ajax/mesh-abi-peer-sizes ^0.1.0, @ajax/mesh-abi-exchange ^0.1.0, @ajax/mesh-abi-host-mload ^0.1.0
dependents
@ajax/mesh-peer-relay
keywords
mesh alphaos fleet peer tcp links fleet
homepage
https://github.com/thomasdavis/alpha-c-mesh/tree/main/packages/mesh-peer-link
repository
https://github.com/thomasdavis/alpha-c-mesh
==> 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.