Article View: borland.public.cppbuilder.internet.socket
Article #4951Re: Check for alive status of a TCPIP computer
From: Mark Jacobs
Date: Fri, 19 Nov 2004 16:49
Date: Fri, 19 Nov 2004 16:49
47 lines
2848 bytes
2848 bytes
Simple ping, by MJ. Assumes AnsiString hostname="112.43.255.67"; for example.
1) Drop a TNMPing object from the Fastnet tab onto your form.
2) In the form's header add a global private int pngflg;
3) When you want to ping the station, do this code :-
pngflg=0; NMPing1->Host=hostname; NMPing1->Ping();
while (pngflg==0) { Application->ProcessMessages(); Sleep(100);}
4) Add the following event handlers for the NMPing you dropped on the form :-
//---------------------------------------------------------------------------
void __fastcall TForm1::NMPing1HostUnreachable(TObject *Sender,AnsiString
Host)
{
pngflg=1;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::NMPing1InvalidHost(TObject *Sender)
{
pngflg=2;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::NMPing1Ping(TObject *Sender,AnsiString Host,int
Size,int Time)
{
pngflg=4;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::NMPing1TimeOut(TObject *Sender)
{
pngflg=3;
}
and that's all there is to it.
--
Mark Jacobs
DK Computing
http://www.dkcomputing.co.uk
| "Oliver Ekeis" <ekeis98@gmx.de> schrieb im Newsbeitrag
| news:cnfa3m$5vd$04$1@news.t-online.com...
| > Hi NG,
| >
| > I've got one simple (newbie) question:
| > I want to check, whether a computer within a TCP/IP-network
| > is connected to the network and online. Manually I usally do that
| > with the ping command. But I want to do that with Borland Cpp-
| > Builder 5.0 without using voluminous components. Just simple
| > short cpp code.
Technical Details
Message-ID:
<419e241d@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!213.73.255.4.MISMATCH!newsfeed.multikabel.nl!news2.euro.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<cnfa3m$5vd$04$1@news.t-online.com> <cnkjuq$jdg$02$1@news.t-online.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,b1ce8267f0044ee3 X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Mark Jacobs" <http://www.jacobsm.com/mjmsg?Borland%20Newsgroup> Newsgroups: borland.public.cppbuilder.internet.socket References: <cnfa3m$5vd$04$1@news.t-online.com> <cnkjuq$jdg$02$1@news.t-online.com> Subject: Re: Check for alive status of a TCPIP computer Date: Fri, 19 Nov 2004 16:49:51 -0000 Lines: 49 Organization: DK Computing X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 NNTP-Posting-Host: 81.144.157.8 Message-ID: <419e241d@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1100882973 81.144.157.8 (19 Nov 2004 08:49:33 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!213.73.255.4.MISMATCH!newsfeed.multikabel.nl!news2.euro.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail