C# Class Org.Mentalis.Proxy.Listener

Specifies the basic methods and properties of a Listener object. This is an abstract class and must be inherited.
The Listener class provides an abstract base class that represents a listening socket of the proxy server. Descendant classes further specify the protocol that is used between those two connections.
Inheritance: IDisposable
显示文件 Open project: mcorrientes/Web-Security-Toolset Class Usage Examples

Public Methods

Method Description
Dispose ( ) : void

Disposes of the resources (other than memory) used by the Listener.

Stops listening and disposes all the client objects. Once disposed, this object should not be used anymore.

GetClientAt ( int Index ) : Client

Returns the requested client from the client list.

If the specified index is invalid, the GetClientAt method returns null.

GetClientCount ( ) : int

Returns the number of clients in the client list.

GetLocalExternalIP ( ) : IPAddress

Returns an external IP address of this computer, if present.

If this computer does not have any configured IP address, this method returns the IP address 0.0.0.0.

GetLocalInternalIP ( ) : IPAddress

Returns an internal IP address of this computer, if present.

If this computer does not have any configured IP address, this method returns the IP address 0.0.0.0.

Listener ( int Port, IPAddress Address ) : System

Initializes a new instance of the Listener class.

For the security of your server, try to avoid to listen on every network card (IPAddress.Any). Listening on a local IP address is usually sufficient and much more secure.

OnAccept ( IAsyncResult ar ) : void

Called when there's an incoming client connection waiting to be accepted.

Start ( ) : void

Starts listening on the selected IP address and port.

ToString ( ) : string

Returns a string representation of this object.

Protected Methods

Method Description
AddClient ( Client client ) : void

Adds the specified Client to the client list.

A client will never be added twice to the list.

IsLocalIP ( IPAddress IP ) : bool

Checks whether the specified IP address is a local IP address or not.

IsRemoteIP ( IPAddress IP ) : bool

Checks whether the specified IP address is a remote IP address or not.

RemoveClient ( Client client ) : void

Removes the specified Client from the client list.

Restart ( ) : void

Restarts listening on the selected IP address and port.

This method is automatically called when the listening port or the listening IP address are changed.

Method Details

AddClient() protected method

Adds the specified Client to the client list.
A client will never be added twice to the list.
protected AddClient ( Client client ) : void
client Client The client to add to the client list.
return void

Dispose() public method

Disposes of the resources (other than memory) used by the Listener.
Stops listening and disposes all the client objects. Once disposed, this object should not be used anymore.
public Dispose ( ) : void
return void

GetClientAt() public method

Returns the requested client from the client list.
If the specified index is invalid, the GetClientAt method returns null.
public GetClientAt ( int Index ) : Client
Index int The index of the requested client.
return Client

GetClientCount() public method

Returns the number of clients in the client list.
public GetClientCount ( ) : int
return int

GetLocalExternalIP() public static method

Returns an external IP address of this computer, if present.
If this computer does not have any configured IP address, this method returns the IP address 0.0.0.0.
public static GetLocalExternalIP ( ) : IPAddress
return System.Net.IPAddress

GetLocalInternalIP() public static method

Returns an internal IP address of this computer, if present.
If this computer does not have any configured IP address, this method returns the IP address 0.0.0.0.
public static GetLocalInternalIP ( ) : IPAddress
return System.Net.IPAddress

IsLocalIP() protected static method

Checks whether the specified IP address is a local IP address or not.
protected static IsLocalIP ( IPAddress IP ) : bool
IP System.Net.IPAddress The IP address to check.
return bool

IsRemoteIP() protected static method

Checks whether the specified IP address is a remote IP address or not.
protected static IsRemoteIP ( IPAddress IP ) : bool
IP System.Net.IPAddress The IP address to check.
return bool

Listener() public method

Initializes a new instance of the Listener class.
For the security of your server, try to avoid to listen on every network card (IPAddress.Any). Listening on a local IP address is usually sufficient and much more secure.
public Listener ( int Port, IPAddress Address ) : System
Port int The port to listen on.
Address System.Net.IPAddress The address to listen on. You can specify IPAddress.Any to listen on all installed network cards.
return System

OnAccept() public abstract method

Called when there's an incoming client connection waiting to be accepted.
public abstract OnAccept ( IAsyncResult ar ) : void
ar IAsyncResult The result of the asynchronous operation.
return void

RemoveClient() protected method

Removes the specified Client from the client list.
protected RemoveClient ( Client client ) : void
client Client The client to remove from the client list.
return void

Restart() protected method

Restarts listening on the selected IP address and port.
This method is automatically called when the listening port or the listening IP address are changed.
There was an error while creating the listening socket.
protected Restart ( ) : void
return void

Start() public method

Starts listening on the selected IP address and port.
There was an error while creating the listening socket.
public Start ( ) : void
return void

ToString() public abstract method

Returns a string representation of this object.
public abstract ToString ( ) : string
return string