C# Class Dazzle.Server.AsyncTcpServer

An Asynchronous TCP Server that makes use of system managed threads and callbacks to stop the server ever locking up.
Mostra file Open project: kellabyte/Dazzle.NET

Public Methods

Method Description
AsyncTcpServer ( IPAddress localaddr, int port ) : System

Constructor for a new server using an IPAddress and Port

AsyncTcpServer ( IPEndPoint localEP ) : System

Constructor for a new server using an end point

Start ( ) : void

Starts the TCP Server listening for new clients.

Stop ( ) : void

Stops the TCP Server listening for new clients and disconnects any currently connected clients.

Write ( TcpClient tcpClient, byte bytes ) : void

Writes a byte array to a given TCP Client

Write ( TcpClient tcpClient, string data ) : void

Writes a string to a given TCP Client

Write ( byte bytes ) : void

Writes a byte array to all clients connected.

Write ( string data ) : void

Writes a string to all clients connected.

Protected Methods

Method Description
HandleData ( byte data, TcpClient client ) : void

Private Methods

Method Description
AcceptTcpClientCallback ( IAsyncResult result ) : void

Callback for the accept tcp client opertaion.

AsyncTcpServer ( ) : System

Private constructor for the common constructor operations.

ReadCallback ( IAsyncResult result ) : void

Callback for the read opertaion.

WriteCallback ( IAsyncResult result ) : void

Callback for the write opertaion.

Method Details

AsyncTcpServer() public method

Constructor for a new server using an IPAddress and Port
public AsyncTcpServer ( IPAddress localaddr, int port ) : System
localaddr System.Net.IPAddress The Local IP Address for the server.
port int The port for the server.
return System

AsyncTcpServer() public method

Constructor for a new server using an end point
public AsyncTcpServer ( IPEndPoint localEP ) : System
localEP System.Net.IPEndPoint The local end point for the server.
return System

HandleData() protected method

protected HandleData ( byte data, TcpClient client ) : void
data byte
client System.Net.Sockets.TcpClient
return void

Start() public method

Starts the TCP Server listening for new clients.
public Start ( ) : void
return void

Stop() public method

Stops the TCP Server listening for new clients and disconnects any currently connected clients.
public Stop ( ) : void
return void

Write() public method

Writes a byte array to a given TCP Client
public Write ( TcpClient tcpClient, byte bytes ) : void
tcpClient System.Net.Sockets.TcpClient The client to write to
bytes byte The bytes to send
return void

Write() public method

Writes a string to a given TCP Client
public Write ( TcpClient tcpClient, string data ) : void
tcpClient System.Net.Sockets.TcpClient The client to write to
data string The string to send.
return void

Write() public method

Writes a byte array to all clients connected.
public Write ( byte bytes ) : void
bytes byte The bytes to send.
return void

Write() public method

Writes a string to all clients connected.
public Write ( string data ) : void
data string The string to send.
return void