C# Class org.GraphDefined.Vanaheimr.Hermod.Sockets.TCP.TCPConnection

An abstract class for all TCP connections.
Inheritance: AReadOnlyLocalRemoteSockets
Show file Open project: Vanaheimr/Hermod

Protected Properties

Property Type Description
Stream NetworkStream
TCPClient System.Net.Sockets.TcpClient

Public Methods

Method Description
Close ( ConnectionClosedBy ClosedBy = ConnectionClosedBy.Server ) : void

Close this TCP connection.

Dispose ( ) : void

Dispose this packet.

EnableTLSServer ( X509Certificate2 TLSCert ) : void
Flush ( ) : void
Read ( UInt16 SleepingTimeMS = 5, UInt32 MaxInitialWaitingTimeMS = 500 ) : Byte

Read a byte value from the TCP connection.

Read ( Byte Buffer, UInt16 SleepingTimeMS = 5, UInt32 MaxInitialWaitingTimeMS = 500 ) : Int32

Read multiple byte values from the TCP connection into the given buffer.

ReadLine ( Int32 MaxLength = 65535, Encoding Encoding = null, UInt16 SleepingTimeMS = 5, UInt32 MaxInitialWaitingTimeMS = 500 ) : String

Read a line from the TCP connection.

ReadString ( Int32 MaxLength = 1024, Encoding Encoding = null, UInt16 SleepingTimeMS = 5, UInt32 MaxInitialWaitingTimeMS = 500 ) : String

Read a string value from the TCP connection.

TCPConnection ( TCPServer TCPServer, TcpClient TCPClient ) : System

Create a new TCP connection.

TryRead ( Byte &Byte, UInt16 SleepingTimeMS = 5, UInt32 MaxInitialWaitingTimeMS = 50 ) : TCPClientResponse

Try to read a byte value from the TCP connection.

WriteLineToResponseStream ( String UTF8Text ) : void

Writes some UTF-8 text to the underlying stream.

WriteToResponseStream ( Byte Byte ) : void

Writes the given byte to the underlying stream.

WriteToResponseStream ( Stream InputStream, Int32 ReadTimeout = 1000, Int32 BufferSize = 65535 ) : void

Reads the given input stream and writes its content to the underlying stream.

WriteToResponseStream ( String UTF8Text ) : void

Writes some UTF-8 text to the underlying stream.

Method Details

Close() public method

Close this TCP connection.
public Close ( ConnectionClosedBy ClosedBy = ConnectionClosedBy.Server ) : void
ClosedBy ConnectionClosedBy
return void

Dispose() public method

Dispose this packet.
public Dispose ( ) : void
return void

EnableTLSServer() public method

public EnableTLSServer ( X509Certificate2 TLSCert ) : void
TLSCert System.Security.Cryptography.X509Certificates.X509Certificate2
return void

Flush() public method

public Flush ( ) : void
return void

Read() public method

Read a byte value from the TCP connection.
public Read ( UInt16 SleepingTimeMS = 5, UInt32 MaxInitialWaitingTimeMS = 500 ) : Byte
SleepingTimeMS System.UInt16 When no data is currently available wait at least this amount of time [milliseconds].
MaxInitialWaitingTimeMS System.UInt32 When no data is currently available wait at most this amount of time [milliseconds].
return Byte

Read() public method

Read multiple byte values from the TCP connection into the given buffer.
public Read ( Byte Buffer, UInt16 SleepingTimeMS = 5, UInt32 MaxInitialWaitingTimeMS = 500 ) : Int32
Buffer Byte An array of byte values.
SleepingTimeMS System.UInt16 When no data is currently available wait at least this amount of time [milliseconds].
MaxInitialWaitingTimeMS System.UInt32 When no data is currently available wait at most this amount of time [milliseconds].
return System.Int32

ReadLine() public method

Read a line from the TCP connection.
public ReadLine ( Int32 MaxLength = 65535, Encoding Encoding = null, UInt16 SleepingTimeMS = 5, UInt32 MaxInitialWaitingTimeMS = 500 ) : String
MaxLength System.Int32 The maximal length of the string.
Encoding System.Text.Encoding The character encoding of the string (default: UTF8).
SleepingTimeMS System.UInt16 When no data is currently available wait at least this amount of time [milliseconds].
MaxInitialWaitingTimeMS System.UInt32 When no data is currently available wait at most this amount of time [milliseconds].
return String

ReadString() public method

Read a string value from the TCP connection.
public ReadString ( Int32 MaxLength = 1024, Encoding Encoding = null, UInt16 SleepingTimeMS = 5, UInt32 MaxInitialWaitingTimeMS = 500 ) : String
MaxLength System.Int32 The maximal length of the string.
Encoding System.Text.Encoding The character encoding of the string (default: UTF8).
SleepingTimeMS System.UInt16 When no data is currently available wait at least this amount of time [milliseconds].
MaxInitialWaitingTimeMS System.UInt32 When no data is currently available wait at most this amount of time [milliseconds].
return String

TCPConnection() public method

Create a new TCP connection.
public TCPConnection ( TCPServer TCPServer, TcpClient TCPClient ) : System
TCPServer TCPServer
TCPClient System.Net.Sockets.TcpClient
return System

TryRead() public method

Try to read a byte value from the TCP connection.
public TryRead ( Byte &Byte, UInt16 SleepingTimeMS = 5, UInt32 MaxInitialWaitingTimeMS = 50 ) : TCPClientResponse
Byte Byte The byte value OR 0x00 if nothing could be read.
SleepingTimeMS System.UInt16 When no data is currently available wait at least this amount of time [milliseconds].
MaxInitialWaitingTimeMS System.UInt32 When no data is currently available wait at most this amount of time [milliseconds].
return TCPClientResponse

WriteLineToResponseStream() public method

Writes some UTF-8 text to the underlying stream.
public WriteLineToResponseStream ( String UTF8Text ) : void
UTF8Text String Some UTF-8 text.
return void

WriteToResponseStream() public method

Writes the given byte to the underlying stream.
public WriteToResponseStream ( Byte Byte ) : void
Byte Byte A single byte.
return void

WriteToResponseStream() public method

Reads the given input stream and writes its content to the underlying stream.
public WriteToResponseStream ( Stream InputStream, Int32 ReadTimeout = 1000, Int32 BufferSize = 65535 ) : void
InputStream Stream A data source.
ReadTimeout System.Int32 A read timeout on the source.
BufferSize System.Int32 The buffer size for reading.
return void

WriteToResponseStream() public method

Writes some UTF-8 text to the underlying stream.
public WriteToResponseStream ( String UTF8Text ) : void
UTF8Text String Some UTF-8 text.
return void

Property Details

Stream protected property

protected NetworkStream Stream
return NetworkStream

TCPClient protected property

protected TcpClient,System.Net.Sockets TCPClient
return System.Net.Sockets.TcpClient