ClintHeyer.Httpd
Class ConnectionAsync

A implementation that uses .NET asynchronous I/O. Use with a

Field Summary
string basicStringRep
byte[] buffer
string cachedRemoteIp
long lastAction
long lastTransferRate
ClintHeyer.Httpd.ServerManager manager
byte[] readBuffer
ClintHeyer.Httpd.HttpSession session
System.Net.Sockets.Socket socket
string stringRep
ClintHeyer.Httpd.Throttler throttledStream
long transferStart
long transferTotal

Constructor Summary
ConnectionAsync(ClintHeyer.Httpd.ServerManager manager, System.Net.Sockets.Socket socket)
         Constructor

Property Summary
ClintHeyer.Httpd.HttpSession Session
         Gets the session for this connection
long TransferRate
         Gets the last recorded transfer speed (bytes per second)

Method Summary
void BeginRead()
void Close()
         Closes a connection, it's socket, and calls ClintHeyer.Httpd.ServerManager.ConnectionClosed(ClintHeyer.Httpd.Connection) on it's server.
void CloseImpl()
bool GetRecievedData(System.IAsyncResult ar)
bool IsAlive()
         Manually checks if a connection is still alive. If not, initiates close procedure
bool IsClosed()
         Is the connection closed?
bool IsExpired()
         Checks whether connection has expired. If so, triggers closed procedures
void OnRecievedData(System.IAsyncResult ar)
void OnSendComplete(System.IAsyncResult result)
         Notification that send has completed
string RemoteHostname()
         Gets the remote hostname of the client
string RemoteIP()
         Does a reverse lookup on hostname to get IP address (cached)
void SendData(byte[] data, int length, long throttleRate)
         Sends data to a connection
void SetSession(ClintHeyer.Httpd.HttpSession session)
         Sets the session for this connection
string ToBasicString()
         Gets a string representation of connection
string ToString()
         Returns a string representation of connection

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


Field Detail

basicStringRep

private string basicStringRep


buffer

private byte[] buffer


cachedRemoteIp

private string cachedRemoteIp


lastAction

private long lastAction


lastTransferRate

private long lastTransferRate


manager

private ClintHeyer.Httpd.ServerManager manager


readBuffer

private byte[] readBuffer


session

private ClintHeyer.Httpd.HttpSession session


socket

private System.Net.Sockets.Socket socket


stringRep

private string stringRep


throttledStream

private ClintHeyer.Httpd.Throttler throttledStream


transferStart

private long transferStart


transferTotal

private long transferTotal

Constructor Detail

ConnectionAsync

public ConnectionAsync(ClintHeyer.Httpd.ServerManager manager,
                       System.Net.Sockets.Socket socket)

Constructor

Parameters:
manager - ServerManager connection belongs too
socket - Socket that connection uses
Property Detail

Session

public ClintHeyer.Httpd.HttpSession Session

Gets the session for this connection


TransferRate

public long TransferRate

Gets the last recorded transfer speed (bytes per second)

Method Detail

BeginRead

private void BeginRead()


Close

public void Close()

Closes a connection, it's socket, and calls ClintHeyer.Httpd.ServerManager.ConnectionClosed(ClintHeyer.Httpd.Connection) on it's server.


CloseImpl

private void CloseImpl()


GetRecievedData

private bool GetRecievedData(System.IAsyncResult ar)


IsAlive

public bool IsAlive()

Manually checks if a connection is still alive. If not, initiates close procedure

Returns:

IsClosed

public bool IsClosed()

Is the connection closed?

Returns:
Is the connection closed

IsExpired

public bool IsExpired()

Checks whether connection has expired. If so, triggers closed procedures

Returns:

OnRecievedData

private void OnRecievedData(System.IAsyncResult ar)


OnSendComplete

public void OnSendComplete(System.IAsyncResult result)

Notification that send has completed

Parameters:
result -

RemoteHostname

public string RemoteHostname()

Gets the remote hostname of the client

Returns:

RemoteIP

public string RemoteIP()

Does a reverse lookup on hostname to get IP address (cached)

Returns:
IP address of client

SendData

public void SendData(byte[] data,
                     int length,
                     long throttleRate)

Sends data to a connection

Parameters:
data - Data
length - Length
throttleRate - Throttle rate. Use a number less than zero for no throttling
Throws:
ClintHeyer.Httpd.ConnectionClosedException - Connection has been closed

SetSession

public void SetSession(ClintHeyer.Httpd.HttpSession session)

Sets the session for this connection

Parameters:
session - Session

ToBasicString

public string ToBasicString()

Gets a string representation of connection

Returns:

ToString

public string ToString()

Returns a string representation of connection

Returns: