Creates a TCP client interface.
When options.socket is provided the interface adopts it (it is an
inbound/server-spawned connection) and never reconnects. Otherwise it is
the initiator and reconnects after drops per the reconnect options.
Protected_Whether a terminal closed event has already been dispatched for the
current connection episode (dedupe guard).
Protected_AbortController for the current reconnect wait, so disconnect() can
cancel an in-flight backoff immediately.
Protected_Reconnect attempt counter for the current drop episode. Reset to 0 at the start of each Interface._runReconnectLoop run.
Protected_Single-flight guard: only one reconnect loop runs at a time.
Whether automatic reconnection is enabled for this initiator interface.
Nominal physical bitrate of this interface in bits per second
(self.bitrate on RNS.Interfaces.Interface in the Python reference,
default 62500). Each interface overrides this with its medium's rate.
Used by TransportCore.prioritizeInterfaces() to order the interface set
highest-bitrate-first (mirrors the Python reference's
Transport.prioritize_interfaces); the per-bitrate link-timeout and
announce-rate-limit behaviours that also build on it are tracked as
Phase 2 of work doc #20. Configured bitrates below
Reticulum.MINIMUM_BITRATE are ignored (matching Python).
Per-dial connect timeout in seconds.
Permanent stop signal read by the reconnect loop. Set by disconnect().
Maximum reconnection attempts per drop. Infinity retries forever.
Seconds to wait between reconnection attempts.
The underlying socket (if any).
Protected_Protected
Applies the TCP socket tuning the Python reference applies on every
(re)connect: TCP_NODELAY and SO_KEEPALIVE with the platform-appropriate
initial probe delay. Node does not expose the granular Linux
TCP_USER_TIMEOUT/TCP_KEEPCNT/TCP_KEEPINTVL knobs, so this is
setKeepAlive-only parity.
Protected_Protected
Signals the reconnect loop to stop and cancels any in-flight backoff.
Client subclasses call this at the top of their disconnect().
Protected_Protected
Dispatches a terminal closed event exactly once per connection episode.
Protected_Protected
Dials the remote host (with the configured connect timeout), applies TCP
keepalive tuning, sets up the RNS streams, and dispatches connected.
Used both for the initial connection and for each reconnect attempt.
Resolves once connected; rejects on failure.
Protected_Protected
Called when the underlying connection drops (the inbound stream ends or
errors). For an initiator with auto-reconnect enabled and not deliberately
detached, dispatches disconnected and kicks off the reconnect loop;
otherwise dispatches a terminal closed event.
Matches the Python reference read_loop, which reconnects the initiator
on any termination and tears down (non-reconnecting) everyone else.
Protected_Protected
Initializes shared reconnect state from constructor options. Called by client interface subclasses (TCP, WebSocket) that support reconnection.
Subclasses must also set Interface.initiator: true for an
outbound dialer, false for an adopted/server-spawned socket.
Protected_Protected
Runs the single-flight reconnect loop. Repeatedly waits reconnectWait
seconds then attempts to re-establish the connection via the subclass
_establishConnection() hook, until it succeeds, the interface is
detached, or maxReconnectTries is exceeded (terminal closed).
Each attempt fires a reconnecting event with the upcoming attempt
number, the wait, and the cap, for observability. A successful reconnect
fires connected (via _establishConnection).
Protected_Protected
Resolves after ms, or immediately if signal aborts. Used so
disconnect() can cancel an in-flight reconnect backoff at once.
The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.
Optionaloptions: boolean | AddEventListenerOptionsOptional hook invoked by import("../transport/transport.js").TransportCore#addInterface with the transport that owns this interface, right after the interface is attached.
The base implementation is a no-op. Interfaces that spawn sub-interfaces
dynamically — notably AutoInterface, which discovers peers and
spawns one per peer — override it to remember the transport so the spawned
peers can be auto-registered without a separate Reticulum global (the
Python reference uses the global RNS.Transport.add_interface for this).
Overriders should also register any peers spawned before the transport was
attached, so the addInterface/connect call order doesn't matter.
Establishes the TCP connection (or adopts the provided socket) and starts the inbound loop.
For an initiator whose first dial fails with auto-reconnect enabled, the
promise rejects (so the caller knows the first attempt failed) but the
reconnect loop keeps retrying in the background. Mirrors the Python
reference initial_connect, which spawns a background reconnect thread on
the first failure.
Tears down the socket, cancels any pending reconnect, and marks the
interface offline. Dispatches a terminal disconnected followed by
closed.
The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().
The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.
Optionaloptions: boolean | EventListenerOptionsStaticgetReturns the JSON Schema describing the options accepted by the
TCPClientInterface constructor (excluding the internal socket
adoption option). Drives dynamically-generated setup UIs.
A JSON Schema object.
Reticulum interface that connects to a remote node over a TCP socket.
Wraps the Node.js
net.Socketinto RNS streams with HDLC or KISS framing. Used both for outbound client connections and (via a server) for inbound ones.