PeanutButter
Loading...
Searching...
No Matches
PeanutButter.SimpleTcpServer.TcpServer Class Referenceabstract

Provides the base TCP server upon which more complex TCP-based servers can be built. More...

Inheritance diagram for PeanutButter.SimpleTcpServer.TcpServer:
PeanutButter.SimpleTcpServer.ITrackingDisposable PeanutButter.SimpleHTTPServer.HttpServerBase PeanutButter.SimpleHTTPServer.HttpServer

Public Member Functions

void Start ()
 Start the server.
void Stop ()
 Stop the server.
virtual void Dispose ()
 Disposes the server (stops it if it is running)

Protected Member Functions

 TcpServer (int minPort=5000, int maxPort=32000)
 Construct the server with a random port within the provided range.
 TcpServer (int port)
 Construct the server with the explicitly-provided port.
void Init ()
 Override in derived classes: this initializes the server system.
void Log (string message, params object[] parameters)
 Provides a convenience logging mechanism which outputs via the established LogAction.
IProcessor CreateProcessorFor (TcpClient client)
 Create a processor for a particular TCP client.
virtual int NextRandomPort ()
 Guesses the next random port to attempt to bind to.

Properties

bool Disposed [get]
 Flag: when true, this server has been disposed.
int MaxShutDownTime = 1000 [get, set]
 Maximum time, in milliseconds, to wait on the listener task when shutting down.
bool LogRandomPortDiscovery [get, set]
 Whether or not to log random port discovery processes.
Action< string > LogAction = Console.WriteLine [get, set]
 Action to employ when logging (defaults to logging to the console)
int Port [get, protected set]
 Port which this server has bound to.
bool IsListening [get]
 Flag exposing listening state.

Detailed Description

Provides the base TCP server upon which more complex TCP-based servers can be built.

Constructor & Destructor Documentation

◆ TcpServer() [1/2]

PeanutButter.SimpleTcpServer.TcpServer.TcpServer ( int minPort = 5000,
int maxPort = 32000 )
protected

Construct the server with a random port within the provided range.

Parameters
minPort
maxPort

◆ TcpServer() [2/2]

PeanutButter.SimpleTcpServer.TcpServer.TcpServer ( int port)
protected

Construct the server with the explicitly-provided port.

Parameters
port

Member Function Documentation

◆ CreateProcessorFor()

IProcessor PeanutButter.SimpleTcpServer.TcpServer.CreateProcessorFor ( TcpClient client)
abstractprotected

Create a processor for a particular TCP client.

Parameters
client
Returns

◆ Log()

void PeanutButter.SimpleTcpServer.TcpServer.Log ( string message,
params object[] parameters )
protected

Provides a convenience logging mechanism which outputs via the established LogAction.

Parameters
message
parameters

◆ NextRandomPort()

virtual int PeanutButter.SimpleTcpServer.TcpServer.NextRandomPort ( )
protectedvirtual

Guesses the next random port to attempt to bind to.

Returns

Property Documentation

◆ Disposed

bool PeanutButter.SimpleTcpServer.TcpServer.Disposed
get

Flag: when true, this server has been disposed.

Implements PeanutButter.SimpleTcpServer.ITrackingDisposable.


The documentation for this class was generated from the following file:
  • source/SimpleServers/PeanutButter.SimpleTcpServer/TcpServer.cs