Indy 9 | Content | Index | Reference

TIdSocketHandles
Hierarchy, Properties, Methods, See Also, Unit: IdSocketHandle
Collection of socket handles.

    TIdSocketHandles = class(TOwnedCollection)

Unit
IdSocketHandle
Description
The TIdSocketHandles collection contains TIdSocketHandle objects for the TIdTCPServer and TIdUDPServer components in their Bindings property. This permits a server to listen on more than one Port and IP address.

The bindings must meet the following criterion:

- The binding must contain a port.

- The bindings for a server mustNEVER allow duplicates for port or IP/port assignments. (e.g. :30 - :30, 127.0.0.1:30, 127.0.0.1:30)

TIdSocketHandles is a TOwnedCollection descendant that maintains additional information about the ItemClass (TIdSocketHandle) for Items contained in the collection.

TIdSocketHandles contains the DefaultPort number to assign to new TIdSocketHandle instances added to the collection.

TIdSocketHandles.DefaultPort
TIdSocketHandles, See Also
Specifies the default port number used to identify a socket connection.

    property DefaultPort: integer;

Description
DefaultPort is an Integer property that identifies the default port number to assign to a new collection item. DefaultPort will be the value assigned to TIdSocketHandle.Port when the instance is added to the collection.

Note: Many values of DefaultPort are associated, by convention, with a particular service such as ftp or http.

TIdSocketHandles.Items
TIdSocketHandles, See Also
Provides indexed access to the binding items in the collection.

    property Items [Index: Integer]: TIdSocketHandle;

Parameters
Index
Position of the binding collection item in the collection.
Return Value
TIdSocketHandle - The binding found at Index in the collection.
Description
Items is an indexed TIdSocketHandle property. Use Items to access an individual binding item in the collection. The value of the Index parameter corresponds to the Index property of the collection item.

TIdSocketHandles.Add
TIdSocketHandles, See Also
Creates a new collection item instance and adds it to Items.

    function Add: TIdSocketHandle; reintroduce;

Return Value
TIdSocketHandle - The binding added to the collection.
Description
Add is a function that creates a new instance of TIdSocketHandle, and adds the instance to the collection Items.

Add relies on the inherited Add method, and casts the new instance to the appropriate ItemClass (TIdSocketHandle) prior to exiting the method. Add assigns the value in DefaultPort to Port property of the new instance. Add returns the new collection item.

TIdSocketHandles.BindingByHandle
TIdSocketHandles, See Also
Retrieve an Indy socket handle for the socket binding.

    function BindingByHandle(const AHandle: TIdStackSocketHandle): TIdSocketHandle;

Parameters
const AHandle: TIdStackSocketHandle
The protocol stack socket handle binding to locate.
Return Value
TIdSocketHandle - The Indy socket handle for the socket binding, or Nil.
Description
BindingByHandle is a TIdSocketHandle function used to retrieve an Indy socket from the socket handle collection. BindingByHandle examines Items starting with the most recently created item in the collection, and navigates towards the oldest of the collection Items.

The return value for BindingByHandle will be Nil if the socket binding specified by AHandle does not exist in the collection.

TIdSocketHandles.Create
TIdSocketHandles
Constructs and initializes the collection before use.

    constructor Create(AOwner: TComponent); reintroduce;

Description
Create constructs a properly initialized instance of the TIdSocketHandles collection. Create relies on the inherited Create constructor to assign both the Owner and the ItemClass (TIdSocketHandle) of the owned collection.

Note: If an exception is raised in the constructor, the Destroy destructor is called to clean up the failed instance.

Created with Doc-O-Matic 2 donated to Project JEDI. Commercial license available from the Doc-O-Matic site.