Skip to main content

Channels and Transport

A channel (IChannel) only moves bytes. It does not parse Modbus, MC, S7, or custom frames. Protocols sit above channels, so the same device code can move between serial, TCP, UDP, and virtual channels.

States

StateMeaning
CreatedRegistered but not opened
OpeningOpening a port or establishing a connection
OpenRead/write is allowed
FaultedOpen or write failed
ClosedClosed

Calling OpenAsync on an already open channel is harmless. Calling it on Closed or Faulted cleans up the previous transport before reopening. Explicit CloseAsync does not auto-reconnect; the host retries only after Faulted according to ChannelReconnectOptions.

Events

  • StateChanged: channel state changed; failures include Error.
  • DataReceived: a safe copy of received bytes; may run outside the UI thread.
  • PacketTraced: raw TX/RX packets with direction, timestamp, and hex payload for diagnostics.

Implementations

TypePurpose
SerialPortChannelSerial port
TcpClientChannelTCP client
TcpServerChannelTCP server; replies to the most recent client by default
UdpClientChannelUDP client
UdpServerChannelUDP server; replies to the most recent remote endpoint by default
VirtualChannelIn-memory echo channel, optionally backed by an IVirtualResponder

To application code they are all IChannel. See Serial Port, TCP / UDP, Virtual Channel, and Communication Tracing.