Page 1 of 1

Using IcpmSendEcho API function with PB 3.94

Posted: Thu Sep 01, 2005 12:15 am
by Marc
Code updated For 5.20+

Following my post in bug section please find how to use the IcmpSendEcho function with PB 3.94 according with MSDN specification about the ReplyBuffer.
See: http://msdn.microsoft.com/library/defau ... decho.asp.

I hope this is a good help and info...

Code: Select all



EchoMessage.s = "MVPing make a Ping Test"
ResultSize.l = SizeOf(ICMP_ECHO_REPLY) + Len(EchoMessage)
*Result = AllocateMemory(ResultSize) 
*Echo.ICMP_ECHO_REPLY = *Result

If OpenConsole() 
  ConsoleTitle("MVPing")
  Repeat
    ConsoleColor(15,0)
    Print("Adresse IP: ")
    ConsoleColor(10,0)
    sIPAddress.s = Input() 
    PrintN("")
    
    If Len(sIPAddress ) > 0 
      hFile.l = IcmpCreateFile_() 
      IPAddress.l=MakeIPAddress(Val(StringField(sIPAddress,1,".")),Val(StringField(sIPAddress,2,".")),Val(StringField(sIPAddress,3,".")),Val(StringField(sIPAddress+".",4,".")))  
      ConsoleColor(14,0)
      For Boucle.l = 1 To 4 
        lngResult.l = IcmpSendEcho_(hFile, IPAddress, EchoMessage, Len(EchoMessage), 0, *Result, ResultSize, 500) 
        PrintN("Ping " + sIPAddress + " Octets: " + Str(*Echo\DataSize) + " Temps: " + Str(*Echo\RoundTripTime) + " ms TTL:" + StrU(*Echo\Options\Ttl,#PB_Byte))
        Delay(500)
      Next 
      IcmpCloseHandle_(hFile)
    EndIf 
  Until sIPAddress= ""
  FreeMemory(*Result)
EndIf
End


Posted: Fri Sep 23, 2005 11:42 pm
by dell_jockey
Bon soir Marc,

for any IP address I get the following lines back:

Code: Select all

<IP or domain name> Octets: 0  Temps 1507348 ms TTL=77
The zero-bytes value may be correct, as the lines were printed rather fast. The ping times must be wrong, perhaps an overflow somewhere?


//EDIT: ok, the above error report is only valid for domain names, not when using IP addresses directly. With IP addresses it works perfectly well. Apparently, domain names don't get resolved into IP addresses.

salut