NetSamples.Common.Net
Class TcpServer

A TCP Server class. Creates a TCP Server that listens for incoming connections. Uses the Network classes (IP Helper wrappers) do determine which interfaces to listen on.

Field Summary
System.Net.IPAddress[] addresses
System.Net.IPEndPoint[] endpoints
NetSamples.Common.Net.TcpAsyncListener[] Listeners
         The listeners.
int port
bool stop

Constructor Summary
TcpServer()
         Constructor.
TcpServer(int port)
         Constructor.

Property Summary
System.Net.IPAddress[] Addresses
         The set of IP Addresses that the service is listening on.
System.Net.IPEndPoint[] EndPoints
         The set of IP Addresses that the service is listening on. Only valid after the server has been started.
int Port
         The port that the server listens on.

Method Summary
void BuildEndPoints()
void OnAcceptSocket(System.IAsyncResult result)
         Internal event handler for the Accept event on the servers socket. Raises the Accept event in this class so that users of the server can handle incoming connections. Clients of this event are expected to close the socket when they are finished.
void Start()
         Starts the server listening on the specified endpoint.
void Stop()
         Stops the server.

Methods inherited from class System.Object
Equals, Finalize, GetHashCode, GetType, MemberwiseClone, ToString

Event Summary
NetSamples.Common.Net.TcpAcceptEventHandler Accept
         Accept event.


Field Detail

addresses

private System.Net.IPAddress[] addresses


endpoints

private System.Net.IPEndPoint[] endpoints


Listeners

protected NetSamples.Common.Net.TcpAsyncListener[] Listeners

The listeners.


port

protected int port


stop

private bool stop

Constructor Detail

TcpServer

public TcpServer()

Constructor.


TcpServer

public TcpServer(int port)

Constructor.

Property Detail

Addresses

public System.Net.IPAddress[] Addresses

The set of IP Addresses that the service is listening on.


EndPoints

public System.Net.IPEndPoint[] EndPoints

The set of IP Addresses that the service is listening on. Only valid after the server has been started.


Port

public int Port

The port that the server listens on.

Method Detail

BuildEndPoints

private void BuildEndPoints()


OnAcceptSocket

protected void OnAcceptSocket(System.IAsyncResult result)

Internal event handler for the Accept event on the servers socket. Raises the Accept event in this class so that users of the server can handle incoming connections. Clients of this event are expected to close the socket when they are finished.


Start

public void Start()

Starts the server listening on the specified endpoint.


Stop

public void Stop()

Stops the server.

Event Detail

Accept

public NetSamples.Common.Net.TcpAcceptEventHandler Accept

Accept event.