Internet Direct (Indy) Version 9.0.2 Beta
TIdIOHandlerSocket.ConnectClient
Establisheds a remote connection for the input/output handler.

procedure ConnectClient(const AHost: string; const APort: Integer; const ABoundIP: string; const ABoundPort: Integer; const ABoundPortMin: Integer; const ABoundPortMax: Integer; const ATimeout: Integer); override;
Parameters
const AHost: string
Address of the remote system for the client connection.

const APort: Integer
Port number for the remote connection.

const ABoundIP: string
IP Address bound to the local system.

const ABoundPort: Integer
Port number bound to the local computer.

const ABoundPortMin: Integer
Minimum bound port number for the local system.

const ABoundPortMax: Integer
Maximum bound port number for the local system.

const ATimeout: Integer = IdTimeoutDefault
Number of milliseconds to wait before a connection attempt fails. Default value is IdTimeoutDefault.

Description
ConnectClient is an overriden procedure in TIdIOHandlerSocket that implements the mechanism that allows an input/output handler to prepare and establish a client connection to a remote computer system using the input parameters.

ConnectClient calls the inherited ConnectClient method, allocates and Binds the socket handle in Binding using the values specified in ABoundIP, ABoundPort, ABoundPortMin, and ABoundPortMax.

If the value in AHost is a host name instead of an IP address, ConnectClient will trigger the OnStatus event to indicate that the address will be resolved prior to setting the peer address and port number for the physical connection in Binding.

ConnectClient will also set the socket options required for UseNage support.

ConnectClient also triggers the OnStatus event handler to indicate that the connection will be opened to the peer client connection prior to trying to open the connection with the timeout value specified in ATimeout.

ConnectClient uses a thread to connect to the remote computer system to allow use of a timeout value in Connect while respecting the operation of the TIdAntifreeze component when present. If the connection thread is terminated with an exception message, ConnectClient can raise an EIdConnectException exception with the exception messasge from the threaded connection. If the connection thread is terminated without an exception message prior to being Connected, ConnectClient can raise an EIdConnectTimeout exception.

Use Connected to detemine if the physical connection has been established after a call to ConnectClient.