Naanou.ResourceExchange
Class NaanouServerManager

Adds random port binding functionality to the usual ServerManagerAsync class

Field Summary
int BIND_ATTEMPT_MAX
         How many attempts should be made to bind to a port
int BIND_RANDOM_MAX
         Random number bound to be added to base port

Fields inherited from class ClintHeyer.Httpd.ServerManagerAsync
address, connections, port, socket

Fields inherited from class ClintHeyer.Httpd.ServerManager
url

Fields inherited from class ClintHeyer.Httpd.Context
configuration, contexts, padlock, parent, requiresSession, sessionManager, throttleRate

Constructor Summary
NaanouServerManager(string address, int basePort)
         Constructor

Property Summary
int Port
         Gets port server is running on

Properties inherited from class ClintHeyer.Httpd.ServerManagerAsync
Address, Connections

Properties inherited from class ClintHeyer.Httpd.ServerManager
TicketIssuer, Url

Properties inherited from class ClintHeyer.Httpd.Context
Lock, Parent, RequiresSession, ServerManager, SessionManager, ThrottleRate

Method Summary
void BindSocket(int port)
         Binds the server to a port. If it cannot bind it picks a random port between port and BIND_RANDOM_MAX.

Methods inherited from class ClintHeyer.Httpd.ServerManagerAsync
AllowConnection, Close, ConnectionClosed, GCConnections, OnConnectRequest

Methods inherited from class ClintHeyer.Httpd.ServerManager
Finalize, GetMimeType, HandleRequest, LoadConfig, SaveConfig

Methods inherited from class ClintHeyer.Httpd.Context
AddContext, AddResponseHandler, CanHandleRequest, GetContexts, GetResponseHandler, Handle, IConfigurable.Get, IConfigurable.GetBool, IConfigurable.GetFloat, IConfigurable.GetInt, IConfigurable.GetString, OnReplyCompleted, OnReplyCompletedEvent, OnReplyStarted, OnReplyStartedEvent, OnThrottleChange, OnThrottleChangeEvent, RemoveContext

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

Events inherited from class ClintHeyer.Httpd.Context
ReplyCompleted, ReplyStarted, ThrottleChange


Field Detail

BIND_ATTEMPT_MAX

public int BIND_ATTEMPT_MAX

How many attempts should be made to bind to a port


BIND_RANDOM_MAX

public int BIND_RANDOM_MAX

Random number bound to be added to base port

Constructor Detail

NaanouServerManager

public NaanouServerManager(string address,
                           int basePort)

Constructor

Parameters:
address - IP address or hostname to advertise as the server address
basePort - Base port, or -1 for a random port
Property Detail

Port

public int Port

Gets port server is running on

Method Detail

BindSocket

protected void BindSocket(int port)

Binds the server to a port. If it cannot bind it picks a random port between port and BIND_RANDOM_MAX.

Parameters:
port - Port number, or -1 for a random port
Throws:
System.Net.Sockets.SocketException - If random port binding fails after BIND_ATTEMPT_MAX attempts.