Skip to main content

Class TCPConnection

A TCP/IP connection to a Brainboxes device over Ethernet. This is the most common connection type for both ED-series (Remote IO) and ES-series (Ethernet to Serial) devices.

Assembly: Brainboxes.IO.dll
View Source
Declaration
public class TCPConnection : Connection, IConnection, IDisposable

Inheritance: System.Object -> Brainboxes.IO.Connection

Implements:
Brainboxes.IO.IConnection, System.IDisposable

Properties

Port

The TCP port of the Connection to the Brainboxes Device e.g. "9500"

View Source
Declaration
public int Port { get; set; }

ConnectionTimeout

Connection timeout for the socket in milliseconds, default 20 seconds This is approximately the same as the TCPClient connection timeout, however unlike the TCPClient, this connection timeout can be altered

View Source
Declaration
public int ConnectionTimeout { get; set; }

Timeout

The connection and stream timeouts (for both stream read and stream write), measured in millseconds

View Source
Declaration
public override int Timeout { get; set; }

Fields

DEFAULT_ASCII_PORT

The default port for ASCII

View Source
Declaration
public static readonly int DEFAULT_ASCII_PORT

DEFAULT_MODBUSTCP_PORT

The default port for Modbus TCP

View Source
Declaration
public static readonly int DEFAULT_MODBUSTCP_PORT

IP

The IP address of the Connection to the Brainboxes Device e.g. "192.168.0.1"

View Source
Declaration
public readonly string IP

_port

The TCP port of the connection to the Brainboxes Device

View Source
Declaration
protected int _port

Methods

_computeIsConnectedValue()

Computes whether the socket is connected by making a nonblocking, zero-byte Send call. This method has no side effects - it just returns the computed state.

View Source
Declaration
protected override bool _computeIsConnectedValue()
Returns

System.Boolean

_newValueIsConnected()

Updates IsConnected and handles socket cleanup on errors. Called by polling to refresh the cache.

View Source
Declaration
protected override void _newValueIsConnected()

_computeIsAvailableValue()

Computes whether the device is available by sending a ping. This method has no side effects - it just returns the computed state.

View Source
Declaration
protected override bool _computeIsAvailableValue()
Returns

System.Boolean

_newValueIsAvailable()

sends a ping to the device and determines if it is still available on the network

View Source
Declaration
protected override void _newValueIsAvailable()

ToString()

ToString

View Source
Declaration
public override string ToString()
Returns

System.String

_connect()

Connect to the Brainboxes Device on the specified IP address and port, within the ConnectionTimeout

View Source
Declaration
protected override void _connect()

_disconnect()

close this connection to the Brainboxes Device

View Source
Declaration
protected override void _disconnect()

Implements