C# Class NetworkCommsDotNet.Connections.TCP.TCPConnection

A connection object which utilises TCP to communicate between peers.
Inheritance: IPConnection
显示文件 Open project: MarcFletcher/NetworkComms.Net Class Usage Examples

Public Methods

Method Description
GetConnection ( ConnectionInfo connectionInfo, SendReceiveOptions defaultSendReceiveOptions, SSLOptions sslOptions, bool establishIfRequired = true ) : TCPConnection

Create a TCP connection with the provided connectionInfo and sets the connection default SendReceiveOptions. If there is an existing connection that is returned instead. If a new connection is created it will be registered with NetworkComms and can be retrieved using NetworkComms.GetExistingConnection(ConnectionInfo) and overrides.

GetConnection ( ConnectionInfo connectionInfo, SendReceiveOptions defaultSendReceiveOptions, bool establishIfRequired = true ) : TCPConnection

Create a TCP connection with the provided connectionInfo and sets the connection default SendReceiveOptions. If there is an existing connection that is returned instead. If a new connection is created it will be registered with NetworkComms and can be retrieved using NetworkComms.GetExistingConnection(ConnectionInfo) and overrides.

GetConnection ( ConnectionInfo connectionInfo, bool establishIfRequired = true ) : TCPConnection

Create a TCPConnection with the provided connectionInfo. If there is an existing connection that will be returned instead. If a new connection is created it will be registered with NetworkComms and can be retrieved using NetworkComms.GetExistingConnection(ConnectionInfo) and overrides.

Protected Methods

Method Description
CloseConnectionSpecific ( bool closeDueToError, int logLocation ) : void
EstablishConnectionSpecific ( ) : void
SendStreams ( StreamTools streamsToSend, double maxSendTimePerKB, long totalBytesToSend ) : double[]
StartIncomingDataListen ( ) : void

Private Methods

Method Description
CertificateSelectionCallback ( object sender, string targetHost, X509CertificateCollection localCertificates, X509Certificate remoteCertificate, string acceptableIssuers ) : X509Certificate

Certificate selection callback

CertificateValidationCallback ( object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors ) : bool

Callback used to determine if the provided certificate should be accepted

ConfigureSSLStream ( ) : void

Configure the SSL stream from this connection

ConnectSocket ( ) : void

If we were not provided with a tcpClient on creation we need to create one

ExistingLocalListenEndPoints ( ) : List
ExistingLocalListenEndPoints ( IPAddress ipAddress ) : List
GetConnection ( ConnectionInfo connectionInfo, SendReceiveOptions defaultSendReceiveOptions, StreamSocket socket, bool establishIfRequired ) : TCPConnection

Internal TCPConnection creation which hides the necessary internal calls

GetConnection ( ConnectionInfo connectionInfo, SendReceiveOptions defaultSendReceiveOptions, TcpClient tcpClient, bool establishIfRequired, SSLOptions sslOptions = null ) : TCPConnection

Internal TCPConnection creation which hides the necessary internal calls

IncomingTCPDataSyncWorker ( ) : void

Synchronous incoming connection data worker

IncomingTCPPacketHandler ( Windows.Storage.Streams.IBuffer buffer ) : Task

Asynchronous incoming connection data delegate

IncomingTCPPacketHandler ( IAsyncResult ar ) : void
Listening ( ) : bool
StartListening ( IPEndPoint newLocalEndPoint, bool useRandomPortFailOver = true, bool allowDiscoverable = false ) : void
StartListening ( List localEndPoints, bool useRandomPortFailOver = true ) : void
StartListening ( bool useRandomPortFailOver = false ) : void
TCPConnection ( ConnectionInfo connectionInfo, SendReceiveOptions defaultSendReceiveOptions, StreamSocket socket ) : System

TCP connection constructor

TCPConnection ( ConnectionInfo connectionInfo, SendReceiveOptions defaultSendReceiveOptions, TcpClient tcpClient, SSLOptions sslOptions ) : System

Method Details

CloseConnectionSpecific() protected method

protected CloseConnectionSpecific ( bool closeDueToError, int logLocation ) : void
closeDueToError bool
logLocation int
return void

EstablishConnectionSpecific() protected method

protected EstablishConnectionSpecific ( ) : void
return void

GetConnection() public static method

Create a TCP connection with the provided connectionInfo and sets the connection default SendReceiveOptions. If there is an existing connection that is returned instead. If a new connection is created it will be registered with NetworkComms and can be retrieved using NetworkComms.GetExistingConnection(ConnectionInfo) and overrides.
public static GetConnection ( ConnectionInfo connectionInfo, SendReceiveOptions defaultSendReceiveOptions, SSLOptions sslOptions, bool establishIfRequired = true ) : TCPConnection
connectionInfo ConnectionInfo ConnectionInfo to be used to create connection
defaultSendReceiveOptions SendReceiveOptions The SendReceiveOptions which will be set as this connections defaults
sslOptions SSLOptions SSLOptions to use with this connection
establishIfRequired bool If true will establish the TCP connection with the remote end point before returning
return TCPConnection

GetConnection() public static method

Create a TCP connection with the provided connectionInfo and sets the connection default SendReceiveOptions. If there is an existing connection that is returned instead. If a new connection is created it will be registered with NetworkComms and can be retrieved using NetworkComms.GetExistingConnection(ConnectionInfo) and overrides.
public static GetConnection ( ConnectionInfo connectionInfo, SendReceiveOptions defaultSendReceiveOptions, bool establishIfRequired = true ) : TCPConnection
connectionInfo ConnectionInfo ConnectionInfo to be used to create connection
defaultSendReceiveOptions SendReceiveOptions The SendReceiveOptions which will be set as this connections defaults
establishIfRequired bool If true will establish the TCP connection with the remote end point before returning
return TCPConnection

GetConnection() public static method

Create a TCPConnection with the provided connectionInfo. If there is an existing connection that will be returned instead. If a new connection is created it will be registered with NetworkComms and can be retrieved using NetworkComms.GetExistingConnection(ConnectionInfo) and overrides.
public static GetConnection ( ConnectionInfo connectionInfo, bool establishIfRequired = true ) : TCPConnection
connectionInfo ConnectionInfo ConnectionInfo to be used to create connection
establishIfRequired bool If true will establish the TCP connection with the remote end point before returning
return TCPConnection

SendStreams() protected method

protected SendStreams ( StreamTools streamsToSend, double maxSendTimePerKB, long totalBytesToSend ) : double[]
streamsToSend NetworkCommsDotNet.Tools.StreamTools
maxSendTimePerKB double
totalBytesToSend long
return double[]

StartIncomingDataListen() protected method

protected StartIncomingDataListen ( ) : void
return void