http OnHostUnreachable event
Return to Introduction  Previous page  Next page
Applies to
WinHTTP component.  

Declaration
property OnHostUnrachable: TNotifyEvent;  

Description
The OnHostUnreachable event occurs if the WinHTTP can not connect to the remote host specified in the URL property. Possible reasons of this problem is:  
1.User currently not connected to the Internet;  
2.Hostname is unknown (check spelling of domain name);  
3.Remote server is down (disconnected from Internet).  

Remarks
1.The OnHostUnreachable event occurs also when user currently working offline (even if connection to the Internet present) and would like to post some data, specified in the POSTData property, to the CGI program. Posting to the CGI programs requires active Internet connection.  

Example
Delphi:
procedure TForm1.WinHTTP1HostUnreachable(Sender: TObject);  
begin  
  Application.MessageBox(PChar('Host http://' + WinHTTP1.HostName + ' is unreachable.'#13'Please check your Internet connection and'#13'retry your HTTP request again later.'),  
                         PChar(Application.Title),  
                         MB_OK or MB_ICONSTOP);  
end;  
 
C++ Builder:
void __fastcall TForm1::WinHTTP1HostUnreachable(TObject *Sender)  
{  
  AnsiString Msg =   
      "Host http://" + WinHTTP1->HostName + " is unreachable.\n\n"  
      "Please check your Internet connection and\n"  
      "try to upgrade this software again later.";  
  Application->MessageBox(Msg.c_str(),   
                          Application->Title.c_str(),  
                          MB_OK | MB_ICONSTOP);  
}  

See also
URL property; OnAnyError event.