C# Класс 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.
Наследование: IDisposable
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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.

Защищенные методы

Метод Описание
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.

Описание методов

AddClient() защищенный Метод

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.
Результат void

Dispose() публичный Метод

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
Результат void

GetClientAt() публичный Метод

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.
Результат Client

GetClientCount() публичный Метод

Returns the number of clients in the client list.
public GetClientCount ( ) : int
Результат int

GetLocalExternalIP() публичный статический Метод

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
Результат System.Net.IPAddress

GetLocalInternalIP() публичный статический Метод

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
Результат System.Net.IPAddress

IsLocalIP() защищенный статический Метод

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.
Результат bool

IsRemoteIP() защищенный статический Метод

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.
Результат bool

Listener() публичный Метод

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.
Результат System

OnAccept() публичный абстрактный Метод

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.
Результат void

RemoveClient() защищенный Метод

Removes the specified Client from the client list.
protected RemoveClient ( Client client ) : void
client Client The client to remove from the client list.
Результат void

Restart() защищенный Метод

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
Результат void

Start() публичный Метод

Starts listening on the selected IP address and port.
There was an error while creating the listening socket.
public Start ( ) : void
Результат void

ToString() публичный абстрактный Метод

Returns a string representation of this object.
public abstract ToString ( ) : string
Результат string