0

In Delphi XE2, when using TIdHTTP.Get, how can I set the connection time-out? (For example, to time-out when the computer is not physically connected to the Internet). I have tried to set the connection time-out with the ConnectTimeout and ReadTimeout TIdHTTP properties, but it does not work:

procedure TForm1.btnGetClick(Sender: TObject);
var
  S: string;
begin
  IdHTTP1.ConnectTimeout := 3000;
  IdHTTP1.ReadTimeout := 3000;

  S := IdHTTP1.Get('http://www.mywebsite.com/program_version.txt');
  lbl1.Caption := S;
end;

Using this code, always after EXACTLY 21 seconds (!) the message dialog "Connect timed out" is displayed (when the computer is not physically connected to the Internet).

So, how can I set the IdHTTP connection time-out? Also, NO DIALOG should be displayed at time-out, but an event should be fired, so I can make my own time-out event handling.

And more generally, how can I detect whether there is no PHYSICAL Internet connection? In this case I wouldn't have to connect at all and save the time-out time (for example, when checking the newest program version online at program start).

Indy version: 10.5.8.0

user1580348
  • 5,721
  • 4
  • 43
  • 105
  • 1
    Take a look at [`this post`](http://stackoverflow.com/a/4272832/960757). It may well be the same case. – TLama Jun 11 '14 at 12:48
  • As always, put stuff like this in a thread so that your GUI is not hindered by the connection timeout. – whosrdaddy Jun 11 '14 at 13:54

0 Answers0