Topic Path: Symbol Reference > Classes > TIdTCPClient Class > TIdTCPClient Properties > ConnectTimeout Property
TIdTCPClient.ConnectTimeout Property

Millseconds to wait for successful completion of a connection attempt.

property ConnectTimeout: Integer;

ConnectTimeout is an Integer property that indicates the maximum number of milliseconds to wait for successful completion of a connection attempt on the client. The default value for ConnectTimeout is 0, and indicates that the timeout value for the underlying protocol stack implementation should be used when establishing the client connection. 

The value in ConnectTimeout is used, along with properties like Host, Port, and ReadTimeout, when the IOHandler for the client is allocated in the Connect method. If the time period in ConnectTimeout has elapsed before successful completion of the Connect method call, an exception relevant to the TIdIOHandler is raised. 

Setting the value in the ConnectTimeout property causes the corresponding property to be updated in an existing IOHandler. The new property value will be available for use in subsequent calls to the Connect method. 

Please note that ConnectTimeout is not used in all TIdIOHandler descendants, and is provided for compatibility purposes across all IOHandler implementations. ConnectTimeout allows a client using a socket-based IOHandler, like TIdIOHandlerSocket or TIdIOHandlerStack, to access the protocol stack mechanisms used to control the connection timeout value.



  // var AClient: TIdTCPClient;

  AClient.Host := ''; // host on intranet
  AClient.Port := 2112;
  AClient.ConnectTimeout := 2500; // 2.5 sec
  AClient.ReadTimeout := 1000;    // 1.0 sec

    AClient.SendCmd('auth guest secret', 'OK');
    // ...
    on E: Exception do
    // handle exception(s)
Copyright 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Post feedback to the Indy Docs Newsgroup.