![]() |
Sylloge
A C# helper library
|
Provides a custom. More...
Inherited by Sylloge.Net.TcpSocket, and Sylloge.Net.UdpSocket.
Public Types | |
enum | KeepAliveType { NONE, CUSTOM, TCP } |
Defines the keep alive handling to use. More... | |
Public Member Functions | |
delegate void | DelegateDataReceived (byte[] data) |
Represents the method that handles when the socket received data. | |
delegate void | DelegateSocketError (System.Exception ex) |
Represents the method to receive the socket error. | |
delegate void | DelegateConnectionCloseError (System.Exception ex) |
Represents the method that will handle when a connection is closed. | |
Socket () | |
The defualt constructor. | |
Socket (string ipAddress, int port) | |
Create an instance of a Connectino class using a specific IP and port. | |
virtual Sylloge.Net.Socket | Copy () |
Create a deep copy of the current connection. | |
void | Dispose () |
Closes the current connection and cleans up. | |
void | Flush () |
Flush any buffered data on the stream. | |
void | Initialize () |
Initialize the basic variables. | |
void | Shutdown () |
Disconect and close the sockets and streams. | |
override string | ToString () |
Returs the IP and port in a string representation. | |
abstract void | Close () |
This method must be overridden in a derived class. | |
abstract void | Connect (Socket.KeepAliveType type=KeepAliveType.NONE, byte[] msg=null, int msInterval=0) |
This method must be overridden in a derived class. | |
abstract void | Listen () |
This method must be overridden in a derived class. | |
abstract void | Send (byte[] data) |
This method must be overridden in a derived class. | |
Protected Member Functions | |
void | OnDataReceived (byte[] data) |
Called when data is recieved. | |
void | OnSocketError (System.Exception ex) |
Called on an unrecoverable socket error. | |
void | OnConnectionCloseError (System.Exception ex) |
Called on a connection closed error. | |
void | Configure (KeepAliveType type, byte[] msg, int msInterval) |
This method should be called after a called to an overridden Connect method. | |
Properties | |
System.IAsyncResult | m_AsyncResult [get, set] |
The async result of the socket communcation operation. | |
System.Windows.Forms.Timer | m_KeepAlive [get, set] |
A keep alive timer that can be used to send custom keep alive messages. | |
System.Threading.Thread | m_ListenThread [get, set] |
The listener thread for a client. | |
byte[] | m_Msg [get, set] |
The custom keep alive message if m_Type == CUSTOM. | |
KeepAliveType | m_KeepAliveType [get, set] |
The keep alive message type. | |
bool | IsClosing [get, set] |
Gets if the current sockets are closing. | |
bool | IsConnected [get, set] |
Gets if the socket is connected. | |
bool | IsLocalHost [get, set] |
Gets if the socket/connection is the local host. | |
string | IpAddress [get, set] |
Gets or sets the IP address to use. | |
bool | IsRunning [get, set] |
Gets if thread is running. | |
int | Port [get, set] |
Gets or sets the port used for the sockets. | |
System.Net.Sockets.Socket | Handle [get, set] |
The underlying socket used to make the connections. | |
System.Net.Sockets.NetworkStream | Stream [get, set] |
The underlying stream used to read and write data. | |
string | IpAndPortString [get] |
Gets a string representation of the IP and port in use. | |
Events | |
DelegateDataReceived | DataReceived |
Occurs when data is received on the listening socket. | |
DelegateSocketError | SocketError |
Occurs when a internal socket error happens. | |
DelegateConnectionCloseError | ConnectionCloseError |
Occurs when there is an error trying to close the connection. |
Sylloge.Net.Socket.Socket | ( | string | ipAddress, |
int | port | ||
) |
abstract void Sylloge.Net.Socket.Close | ( | ) | [pure virtual] |
This method must be overridden in a derived class.
Implemented in Sylloge.Net.TcpSocket, and Sylloge.Net.UdpSocket.
void Sylloge.Net.Socket.Configure | ( | KeepAliveType | type, |
byte[] | msg, | ||
int | msInterval | ||
) | [protected] |
abstract void Sylloge.Net.Socket.Connect | ( | Socket.KeepAliveType | type = KeepAliveType.NONE , |
byte[] | msg = null , |
||
int | msInterval = 0 |
||
) | [pure virtual] |
This method must be overridden in a derived class.
type | The keep alive type to use (defualt NONE) |
msg | The custom keep alive message to send (default null) |
msInterval | The interval to send custom keep alive messages at (default 0) |
Implemented in Sylloge.Net.TcpSocket, and Sylloge.Net.UdpSocket.
virtual Sylloge.Net.Socket Sylloge.Net.Socket.Copy | ( | ) | [virtual] |
Create a deep copy of the current connection.
Reimplemented in Sylloge.Net.TcpSocket, and Sylloge.Net.UdpSocket.
delegate void Sylloge.Net.Socket.DelegateConnectionCloseError | ( | System.Exception | ex | ) |
Represents the method that will handle when a connection is closed.
ex | The System.Exception that occured |
delegate void Sylloge.Net.Socket.DelegateDataReceived | ( | byte[] | data | ) |
Represents the method that handles when the socket received data.
data | The data received |
delegate void Sylloge.Net.Socket.DelegateSocketError | ( | System.Exception | ex | ) |
Represents the method to receive the socket error.
ex | The System.Exception that occured |
void Sylloge.Net.Socket.Dispose | ( | ) |
void Sylloge.Net.Socket.Flush | ( | ) |
void Sylloge.Net.Socket.Initialize | ( | ) |
abstract void Sylloge.Net.Socket.Listen | ( | ) | [pure virtual] |
This method must be overridden in a derived class.
Implemented in Sylloge.Net.TcpSocket, and Sylloge.Net.UdpSocket.
void Sylloge.Net.Socket.OnConnectionCloseError | ( | System.Exception | ex | ) | [protected] |
Called on a connection closed error.
ex | The System.Exception that occured |
void Sylloge.Net.Socket.OnDataReceived | ( | byte[] | data | ) | [protected] |
void Sylloge.Net.Socket.OnSocketError | ( | System.Exception | ex | ) | [protected] |
Called on an unrecoverable socket error.
ex | The System.Exception that occured |
abstract void Sylloge.Net.Socket.Send | ( | byte[] | data | ) | [pure virtual] |
This method must be overridden in a derived class.
data | The data to send |
Implemented in Sylloge.Net.TcpSocket, and Sylloge.Net.UdpSocket.
void Sylloge.Net.Socket.Shutdown | ( | ) |
override string Sylloge.Net.Socket.ToString | ( | ) |
Returs the IP and port in a string representation.
Reimplemented in Sylloge.Net.TcpSocket, and Sylloge.Net.UdpSocket.
System.Net.Sockets.Socket Sylloge.Net.Socket.Handle [get, set] |
string Sylloge.Net.Socket.IpAddress [get, set] |
string Sylloge.Net.Socket.IpAndPortString [get] |
bool Sylloge.Net.Socket.IsClosing [get, set] |
bool Sylloge.Net.Socket.IsConnected [get, set] |
bool Sylloge.Net.Socket.IsLocalHost [get, set] |
bool Sylloge.Net.Socket.IsRunning [get, set] |
System.IAsyncResult Sylloge.Net.Socket.m_AsyncResult [get, set, protected] |
System.Windows.Forms.Timer Sylloge.Net.Socket.m_KeepAlive [get, set, protected] |
KeepAliveType Sylloge.Net.Socket.m_KeepAliveType [get, set, protected] |
System.Threading.Thread Sylloge.Net.Socket.m_ListenThread [get, set, protected] |
byte [] Sylloge.Net.Socket.m_Msg [get, set, protected] |
int Sylloge.Net.Socket.Port [get, set] |
System.Net.Sockets.NetworkStream Sylloge.Net.Socket.Stream [get, set] |
DelegateConnectionCloseError Sylloge.Net.Socket.ConnectionCloseError |
DelegateDataReceived Sylloge.Net.Socket.DataReceived |
DelegateSocketError Sylloge.Net.Socket.SocketError |