🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.web
14 messages
14 total messages Started by John M. Thu, 02 Dec 2004 00:00
indy ping exmaple
#1525
Author: John M.
Date: Thu, 02 Dec 2004 00:00
11 lines
1123 bytes
hi,

i try to find a solution to get the ping of a special host. i have search
for many questions on this topic before, but i could not find any exmaple.

i hope that anybody could give me some exmample. i like to transfer the host
und get back the time or an error.

any ideas how to do?

john
Re: indy ping exmaple
#1526
Author: Remy Lebeau (TeamB)
Date: Thu, 02 Dec 2004 01:37
13 lines
1217 bytes
"John M." <johnnym@yahoo.com> wrote in message
news:41ae5b3a@newsgroups.borland.com...

> i try to find a solution to get the ping of a special host. i have
> search for many questions on this topic before, but i could not
> find any exmaple.

Have you looked at the TIdIcmpClient component yet?  It has a Ping() method
and a ReplyStatus property.


Gambit
Re: indy ping exmaple
#1530
Author: John M.
Date: Thu, 02 Dec 2004 12:27
38 lines
1854 bytes
hi remy,

i tried this here:

IdIcmpClient1->Host = "www.borland.com";
IdIcmpClient1->ReceiveTimeout = 1000;
IdIcmpClient1->Ping();
ShowMessage(IdIcmpClient1->ReplyStatus);

But the function needs two parameters

procedure Ping(ABuffer: String = ''; SequenceID: word = 0);

but i have no ideas, what values should i use

any ideas?

john


"Remy Lebeau (TeamB)" <no.spam@no.spam.com> schrieb im Newsbeitrag
news:41ae71eb@newsgroups.borland.com...
>
> "John M." <johnnym@yahoo.com> wrote in message
> news:41ae5b3a@newsgroups.borland.com...
>
> > i try to find a solution to get the ping of a special host. i have
> > search for many questions on this topic before, but i could not
> > find any exmaple.
>
> Have you looked at the TIdIcmpClient component yet?  It has a Ping()
method
> and a ReplyStatus property.
>
>
> Gambit
>
>
Re: indy ping exmaple
#1529
Author: Remy Lebeau (TeamB)
Date: Thu, 02 Dec 2004 17:54
51 lines
2471 bytes
"John M." <johnnym@yahoo.com> wrote in message
news:41af0a1b@newsgroups.borland.com...

> i tried this here:

That code is wrong.  Did you not read Indy's documentation yet?

> IdIcmpClient1->Host = "www.borland.com";

You do not use the Host property.  You pass the hostname to Ping() as a
parameter instead:

    IdIcmpClient1->Ping("www.borland.com");

> ShowMessage(IdIcmpClient1->ReplyStatus);

ReplyStatus is a class, not a string:

    switch( IdIcmpClient1->ReplyStatus->ReplyStatusType )
    {
        case rsEcho:
        {
            AnsiString s = "Reply from " +
IdIcmpClient1->ReplyStatus->FromIpAddress
                 + (": bytes=" +
AnsiString(IdIcmpClient1->ReplyStatus->BytesReceived))
                + (" time=" +
AnsiString(IdIcmpClient1->ReplyStatus->MsRoundTripTime) + "ms")
                + (" TTL=" +
AnsiString(IdIcmpClient1->ReplyStatus->TimeToLive));
            ShowMessage(s);
            break;
        }

        case rsError:
            ShowMessage("Request Error");
            break;
        case rsTimeOut:
            ShowMessage("Request Timed Out");
            break;
        case rsErrorUnreachable:
            ShowMessage("Host Unreachable");
            break;
        case rsErrorTTLExceeded
            ShowMessage("TTL Exceeded");
            break;
    }


Gambit
Re: indy ping exmaple
#1531
Author: John M.
Date: Thu, 02 Dec 2004 21:39
127 lines
4635 bytes
Hi Gambit,

the Ping function need two parameters, that is why my code does not work. i
get this error messages:

[C++ Fehler] main.cpp(865): E2193 Zu wenige Parameter im Aufruf von
'_fastcall TIdIcmpClient::Ping(AnsiString,unsigned short)'

Means like "To few parameters in call of '_fastcall
TIdIcmpClient::Ping(AnsiString,unsigned short)'"

[C++ Fehler] main.cpp(866): E2288 Zeiger auf Struktur auf linker Seite
von -> oder von ->* erforderlich
[C++ Fehler] main.cpp(869): E2288 Zeiger auf Struktur auf linker Seite
von -> oder von ->* erforderlich
[C++ Fehler] main.cpp(870): E2288 Zeiger auf Struktur auf linker Seite
von -> oder von ->* erforderlich
[C++ Fehler] main.cpp(871): E2288 Zeiger auf Struktur auf linker Seite
von -> oder von ->* erforderlich
[C++ Fehler] main.cpp(872): E2288 Zeiger auf Struktur auf linker Seite
von -> oder von ->* erforderlich

Means like "Pointer of structure on the left site from -> or from ->*
necessarily


This is here is my actual code:

void __fastcall TForm1::Button2Click(TObject *Sender)
{
   AnsiString s;
   IdIcmpClient1->Ping("www.borland.com");
   switch(IdIcmpClient1->ReplyStatus->ReplyStatusType)
   {
      case rsEcho:
         s = "Reply from " + IdIcmpClient1->ReplyStatus->FromIpAddress
         + (": bytes=" +
AnsiString(IdIcmpClient1->ReplyStatus->BytesReceived))
         + (" time=" +
AnsiString(IdIcmpClient1->ReplyStatus->MsRoundTripTime) + "ms")
         + (" TTL=" + AnsiString(IdIcmpClient1->ReplyStatus->TimeToLive));
         ShowMessage(s);
      break;

      case rsError:
         ShowMessage("Request Error");
      break;

      case rsTimeOut:
         ShowMessage("Request Timed Out");
      break;

      case rsErrorUnreachable:
         ShowMessage("Host Unreachable");
      break;

      case rsErrorTTLExceeded:
         ShowMessage("TTL Exceeded");
      break;
   }

}
//--------------------------------------------------------------------------
-


Any ideas about the second parameter? I am using Indy 90017

john



"Remy Lebeau (TeamB)" <no.spam@no.spam.com> schrieb im Newsbeitrag
news:41af5738$1@newsgroups.borland.com...
>
> "John M." <johnnym@yahoo.com> wrote in message
> news:41af0a1b@newsgroups.borland.com...
>
> > i tried this here:
>
> That code is wrong.  Did you not read Indy's documentation yet?
>
> > IdIcmpClient1->Host = "www.borland.com";
>
> You do not use the Host property.  You pass the hostname to Ping() as a
> parameter instead:
>
>     IdIcmpClient1->Ping("www.borland.com");
>
> > ShowMessage(IdIcmpClient1->ReplyStatus);
>
> ReplyStatus is a class, not a string:
>
>     switch( IdIcmpClient1->ReplyStatus->ReplyStatusType )
>     {
>         case rsEcho:
>         {
>             AnsiString s = "Reply from " +
> IdIcmpClient1->ReplyStatus->FromIpAddress
>                  + (": bytes=" +
> AnsiString(IdIcmpClient1->ReplyStatus->BytesReceived))
>                 + (" time=" +
> AnsiString(IdIcmpClient1->ReplyStatus->MsRoundTripTime) + "ms")
>                 + (" TTL=" +
> AnsiString(IdIcmpClient1->ReplyStatus->TimeToLive));
>             ShowMessage(s);
>             break;
>         }
>
>         case rsError:
>             ShowMessage("Request Error");
>             break;
>         case rsTimeOut:
>             ShowMessage("Request Timed Out");
>             break;
>         case rsErrorUnreachable:
>             ShowMessage("Host Unreachable");
>             break;
>         case rsErrorTTLExceeded
>             ShowMessage("TTL Exceeded");
>             break;
>     }
>
>
> Gambit
>
>
Re: indy ping exmaple
#1532
Author: Remy Lebeau (TeamB)
Date: Thu, 02 Dec 2004 22:15
32 lines
2161 bytes
"John M." <johnnym@yahoo.com> wrote in message
news:41af8bb4@newsgroups.borland.com...

> the Ping function need two parameters, that is why my code does
> not work. i get this error messages:
<snip>
> Means like "To few parameters in call of '_fastcall
> TIdIcmpClient::Ping(AnsiString,unsigned short)'"

Specify 0 for the second parameter.  That is its default value.

Since you did not specify which version of BCB you are actualing using, I am
going to assume that you are using a version prior to BCB6.  The Delphi
compiler in older BCB versions, particularly BCB5, has a bug where default
parameters for functions and methods are not recognized properly when
generating an HPP header file from Delphi source code.  That bug has been
corrected in BCB6.

> Means like "Pointer of structure on the left site from -> or
> from ->* necessarily

Change references like this:

    IdIcmpClient1->ReplyStatus->SomeFieldName

To this instead:

    IdIcmpClient1->ReplyStatus.SomeFieldName


Gambit
Re: indy ping exmaple
#1434
Author: John M.
Date: Fri, 03 Dec 2004 17:17
64 lines
2765 bytes
Hi remy,

now it works, i tried different web sites and get these results:

www.borland.com
Reply from 192.168.0.3: bytes=72 time=120ms TTL=128

www.gmx.com
Reply from 192.168.0.3: bytes=72 time=3ms TTL=128

www.amazon.com
Reply from 192.168.0.3: bytes=72 time=2ms TTL=128

it is normal that there is always reply from my ipadress???

when i enter
ping www.amazon.com
in my console
i always get a 100% lost of the data i send.

are the results i get right? i looks a bit strange.

john




"Remy Lebeau (TeamB)" <no.spam@no.spam.com> schrieb im Newsbeitrag
news:41af93ff$3@newsgroups.borland.com...
>
> "John M." <johnnym@yahoo.com> wrote in message
> news:41af8bb4@newsgroups.borland.com...
>
> > the Ping function need two parameters, that is why my code does
> > not work. i get this error messages:
> <snip>
> > Means like "To few parameters in call of '_fastcall
> > TIdIcmpClient::Ping(AnsiString,unsigned short)'"
>
> Specify 0 for the second parameter.  That is its default value.
>
> Since you did not specify which version of BCB you are actualing using, I
am
> going to assume that you are using a version prior to BCB6.  The Delphi
> compiler in older BCB versions, particularly BCB5, has a bug where default
> parameters for functions and methods are not recognized properly when
> generating an HPP header file from Delphi source code.  That bug has been
> corrected in BCB6.
>
> > Means like "Pointer of structure on the left site from -> or
> > from ->* necessarily
>
> Change references like this:
>
>     IdIcmpClient1->ReplyStatus->SomeFieldName
>
> To this instead:
>
>     IdIcmpClient1->ReplyStatus.SomeFieldName
>
>
> Gambit
>
>
Re: indy ping exmaple
#1436
Author: Remy Lebeau (TeamB)
Date: Fri, 03 Dec 2004 18:25
17 lines
1598 bytes
"John M." <johnnym@yahoo.com> wrote in message
news:41b09f9a@newsgroups.borland.com...

> it is normal that there is always reply from my ipadress???

No.  It should be Borland's IP address.

> when i enter
> ping www.amazon.com
> in my console
> i always get a 100% lost of the data i send.

Amazon does not reply to ping requests in the first place.


Gambit
Re: indy ping exmaple
#1435
Author: John M.
Date: Fri, 03 Dec 2004 18:53
32 lines
1932 bytes
Hi,

what could be the reason, that there is my ip address und not the one of
borland??

my computer is behind a router, could this be the problem.

is there any other way to ping another computer which will work?

john

"Remy Lebeau (TeamB)" <no.spam@no.spam.com> schrieb im Newsbeitrag
news:41b0afa1$1@newsgroups.borland.com...
>
> "John M." <johnnym@yahoo.com> wrote in message
> news:41b09f9a@newsgroups.borland.com...
>
> > it is normal that there is always reply from my ipadress???
>
> No.  It should be Borland's IP address.
>
> > when i enter
> > ping www.amazon.com
> > in my console
> > i always get a 100% lost of the data i send.
>
> Amazon does not reply to ping requests in the first place.
>
>
> Gambit
>
>
Re: indy ping exmaple
#1437
Author: Remy Lebeau (TeamB)
Date: Fri, 03 Dec 2004 19:47
25 lines
2016 bytes
"John M." <johnnym@yahoo.com> wrote in message
news:41b0b63c@newsgroups.borland.com...

> what could be the reason, that there is my ip address
> und not the one of borland??

I do not know.  Sounds like a bug in TIdIcmpClient.

> my computer is behind a router, could this be the problem.

Maybe.  Is 192.168.0.3 the IP address of your router?  If you use
Microsoft's ping utility at the command prompt, do you get the same results
as TIdIcmpClient?

I am also behind a router.  I receive the appropriate host IP addresses just
fine when using the command-line ping utility, but receive my own when using
TIdIcmpClient.

> is there any other way to ping another computer which will work?

You could try accessing Microsoft's undocumented ICMP.DLL directly.


Gambit
Re: indy ping exmaple
#1438
Author: John M.
Date: Fri, 03 Dec 2004 20:59
55 lines
2960 bytes
hi remy,

> I do not know.  Sounds like a bug in TIdIcmpClient.

perhabs a member of the indy team might read this.  i downloaded and install
Indy_9_00_17_src.zip of the indy project site. do you have a newer version?
perhabs i should update?

> > my computer is behind a router, could this be the problem.
> Maybe.  Is 192.168.0.3 the IP address of your router?  If you use
> Microsoft's ping utility at the command prompt, do you get the same
results
> as TIdIcmpClient?

my router ip is 192.168.0.100

when i try in command line i get this here:

C:\>ping borland.com

Pinging borland.com [207.105.75.31] with 32 bytes of data:

Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 207.105.75.31:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

C:\>ping www.borland.com

Pinging www.borland.com [206.171.41.22] with 32 bytes of data:

Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 206.171.41.22:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

C:\>

this. i thinlk there might be a programm with my configuration, but i do not
have any idea what configuration would be wrong. next i would be great for
my application to know if the configuration is wrong. otherwise the ping
would return wrong values.

> You could try accessing Microsoft's undocumented ICMP.DLL directly.
this will be my last way, i already have seen some example code here. does
ICMP.DLL works with all windows os? so i am mean higher than win 98 or win
me?

john
Re: indy ping exmaple
#1439
Author: Remy Lebeau (TeamB)
Date: Fri, 03 Dec 2004 21:12
19 lines
1842 bytes
"John M." <johnnym@yahoo.com> wrote in message
news:41b0d3b2$1@newsgroups.borland.com...

> perhabs a member of the indy team might read this.

I am a member of the Indy team.  I have already submitted the issue for
Indy's review.

> > You could try accessing Microsoft's undocumented ICMP.DLL directly.

> this will be my last way, i already have seen some example code
> here. does ICMP.DLL works with all windows os?

Tehnically yes, though Microsoft warns against using it.  MS has been saying
for years that ICMP.DLL is going to go away, but it has yet to do so.


Gambit
Re: indy ping exmaple
#1440
Author: John M.
Date: Fri, 03 Dec 2004 21:21
81 lines
3706 bytes
hi,

wenn i ping yahoo instead of borland, it works in my command:

C:\>ping www.yahoo.com

Pinging www.yahoo.akadns.net [216.109.117.110] with 32 bytes of data:

Reply from 216.109.117.110: bytes=32 time=152ms TTL=56
Reply from 216.109.117.110: bytes=32 time=147ms TTL=57
Reply from 216.109.117.110: bytes=32 time=150ms TTL=57
Reply from 216.109.117.110: bytes=32 time=149ms TTL=57

Ping statistics for 216.109.117.110:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 147ms, Maximum = 152ms, Average = 149ms

C:\>

but why are there sites i can ping and other not?

but when i try to ping yahoo.com or www.yahoo.com in my c++ application i
still get:

Reply from 192.168.0.3: bytes=72 time=3ms TTL=128
Reply from 192.168.0.3: bytes=72 time=2ms TTL=128

i have no idea why this does not work. here again my function:

void __fastcall TForm1::Button2Click(TObject *Sender)
{
   AnsiString s;
   IdIcmpClient1->Ping(Edit1->Text,0);
   switch(IdIcmpClient1->ReplyStatus.ReplyStatusType)
   {
      case rsEcho:
         s = "Reply from " + IdIcmpClient1->ReplyStatus.FromIpAddress
         + (": bytes=" +
AnsiString(IdIcmpClient1->ReplyStatus.BytesReceived))
         + (" time=" +
AnsiString(IdIcmpClient1->ReplyStatus.MsRoundTripTime) + "ms")
         + (" TTL=" + AnsiString(IdIcmpClient1->ReplyStatus.TimeToLive));
         Memo1->Lines->Add(s);
      break;

      case rsError:
         ShowMessage("Request Error");
      break;

      case rsTimeOut:
         ShowMessage("Request Timed Out");
      break;

      case rsErrorUnreachable:
         ShowMessage("Host Unreachable");
      break;

      case rsErrorTTLExceeded:
         ShowMessage("TTL Exceeded");
      break;
   }

}

> I am a member of the Indy team.  I have already submitted the issue for
> Indy's review.

this i great. do you know if there are other people with the same problem.
is it a bug or a problem with my system?

> > > You could try accessing Microsoft's undocumented ICMP.DLL directly.
> Tehnically yes, though Microsoft warns against using it.  MS has been
saying
> for years that ICMP.DLL is going to go away, but it has yet to do so.


okay, than i dont use icmp.dll. but how does indy get the ping, doesnt it
use icmp?

john
Re: indy ping exmaple
#1441
Author: Remy Lebeau (TeamB)
Date: Fri, 03 Dec 2004 21:59
26 lines
2046 bytes
"John M." <johnnym@yahoo.com> wrote in message
news:41b0d8ea@newsgroups.borland.com...

> but why are there sites i can ping and other not?

Because 1) not all sites respond to pings, and 2) you are in Germany and the
sites you are pinging are in the USA, so there might be Internet congestion
or blockage getting from one to the other.

> i have no idea why this does not work.

I already explained that.

> do you know if there are other people with the same problem.
> is it a bug or a problem with my system?

I have already duplicated the bug on my own system.

> okay, than i dont use icmp.dll. but how does indy get the ping,
> doesnt it use icmp?

It does not use ICMP.DLL, it implements the ICMP protocol manually.


Gambit
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads