Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check Connection with Internet

Status
Not open for further replies.

safra

Technical User
Jan 24, 2001
319
NL
Hi,

I looked for this on the Internet and also here in the search files. It seems there are several options like using the registry.

However all options I found fail. Whether I am connected or not it always returns the same state. So to me those options do not seems very reliable. I am on an ADSL connection.

Somewhere I found that the only correct way to check a connection is to ping a server.

Does anyone have some tips for me, what the best way is to check a connection with the Internet?

Thanks
Raoul
 
Yeah, I would just ping:

procedure TfrmConnectTest.btnPingClick(Sender: TObject);
begin
IdIcmpClient.Ping();
end;

procedure TfrmConnectTest.IdIcmpClientReply(ASender: TComponent;
const AReplyStatus: TReplyStatus);
begin
if AReplyStatus.ReplyStatusType=rsEcho
then caption:='Connected'
else caption:='Not Connected'
end;

The above example was done using Indy,
which comes with Delphi.

For the component you need to set the
Host property to a server that stays
up and responds to a ping.
 
Thanks, I will stick to that then
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top