Internet Direct (Indy)
Home
PreviousUpNext
TIdTCPClient.ConnectTimeout Property

Millseconds to wait for successful completion of a connection attempt.

Pascal
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.

[Delphi] 

 

  // var AClient: TIdTCPClient;

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

  try
    AClient.Connect;
    AClient.SendCmd('auth guest secret', 'OK');
    // ...
    AClient.Disconnect;
  except
    on E: Exception do
    begin
    // handle exception(s)
    end;
  end;
Internet Direct (Indy) version 10.1.5
Copyright © 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Website http://www.indyproject.org.
Post feedback to the Indy Documentation newsgroup.