ClintHeyer.Httpd
Class ServerManagerAsync

Uses asynchronous communications

Field Summary
string address
System.Collections.ArrayList connections
bool gcInProgress
int port
System.Net.Sockets.Socket 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
ServerManagerAsync(int port)
         Constructor

Property Summary
string Address
         Gets the address this server is bound too
int Connections
int Port
         Gets the port server was started on

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

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

Method Summary
bool AllowConnection(System.IAsyncResult ar)
         Determines whether an initial connection request is allowed.
void BindSocket(int port)
         Binds the server to a port
void Close()
         Shut down server
void ConnectionClosed(ClintHeyer.Httpd.Connection connection)
         A notification from a Connection that it has closed, and that the manager should clean up at its end.
void GCConnections()
void OnConnectRequest(System.IAsyncResult ar)
         Connection request
void StartListening()

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

address

protected string address


connections

protected System.Collections.ArrayList connections


gcInProgress

private bool gcInProgress


port

protected int port


socket

protected System.Net.Sockets.Socket socket

Constructor Detail

ServerManagerAsync

public ServerManagerAsync(int port)

Constructor

Parameters:
port - Port to listen too
Throws:
ClintHeyer.Httpd.ServerBindException - Server cannot bind to specified port
Property Detail

Address

public string Address

Gets the address this server is bound too


Connections

public int Connections


Port

public int Port

Gets the port server was started on

Method Detail

AllowConnection

protected bool AllowConnection(System.IAsyncResult ar)

Determines whether an initial connection request is allowed.

This can be overrided to provide 'hard' over-load protection, by arbitarily dropping socket connection requests, or making the server somewhat invisible to certain requesters by refusing connection.

Parameters:
ar - Async socket connection request result. The System.IAsyncResult.AsyncState property can be cast to a Socket. Do not call System.Net.Sockets.Socket.EndAccept(System.IAsyncResult), or otherwise change socket.
Returns:
True if connection should be allowed

BindSocket

protected void BindSocket(int port)

Binds the server to a port

Parameters:
port - Port number

Close

public void Close()

Shut down server


ConnectionClosed

public void ConnectionClosed(ClintHeyer.Httpd.Connection connection)

A notification from a Connection that it has closed, and that the manager should clean up at its end.

Parameters:
connection -

GCConnections

public void GCConnections()


OnConnectRequest

protected void OnConnectRequest(System.IAsyncResult ar)

Connection request

Parameters:
ar -

StartListening

private void StartListening()