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