Topic Path: Symbol Reference > Classes > TIdStackDotNet Class > TIdStackDotNet Methods > Bind Method
TIdStackDotNet.Bind Method

Associates a local address with a socket handle.

procedure Bind(
    ASocket: TIdStackSocketHandle; 
    const AIP: string; 
    const APort: Integer; 
    const AIPVersion: TIdIPVersion = ID_DEFAULT_IP_VERSION
); override;
Socket handle to bind.
IP address to use for the local network connection.
Port number to use for the local network connection.
IP address family for the IP address. 

Bind is an overridden procedure that implements the method used to access the Bind() API for the protocol stack implementation. 

Bind is used on a disconnected socket prior to calling Connect or Listen

When a socket handle is created, it generally doesn't have enough information to assign the Address family, IP address, and port number for the local network connection. 

If an application does not care what local address is assigned, the value INADDR_ANY is used. The protocol stack will assign an appropriate local network address for the socket handle. 

When the port number 0 (zero), the protocol stack will assign a unique port to the application with a value between 1024 and 5000. 

Bind sets the local association for the socket handle by creating an IPEndPoint using the values in AIP and APort. 

Exceptions occuring in the method are re-raised using either the EIdSocketError or EIdWrapperException exception types.

Copyright 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Post feedback to the Indy Docs Newsgroup.