Represents a single TCP/IP connection.
System Object Bespoke.Common.Net TcpConnectionNamespace: Bespoke.Common.NetAssembly: Bespoke.Common (in Bespoke.Common.dll) Version: 5.0.0.0 (5.0.0.0)
Public Class TcpConnection _
Implements IDisposable
public class TcpConnection : IDisposable
public ref class TcpConnection : IDisposable
TcpConnection objects can be used in conjunction with
TcpServer or as simple
wrappers to a
Socket. Data can be received automatically by the TcpConnection object by invoking the
ReceiveDataAsynchronously method. This mechanism transmits the data asynchronously using Socket.BeginReceive/EndReceive.
Additionally, messages are framed using a 4-byte integer containing the length of the message. The DataReceived event
is raised as complete messages are received. Users can perform their own message handling by not invoking the
ReceiveDataAsynchronously method and accessing the TcpConnection.Client/Reader/Writer properties directly.
When performing manual data handling, in conjunction with a
TcpServer object, set the
ReceiveDataInline
property to false.