Contact Info

Crumbtrail

ActiveXperts.com » Network Component » Network Component Objects » ICMP

ActiveXperts Network Component Icmp Object

ICMP/Ping is one of the most commonly used utilities on the Internet by people and programs, with untold millions of pings flashing every second back and forth between computers. The original PING utility stood for "Packet Internet Groper", and was a package of diagnostic utilities used by DARPA personnel to test the performance of the ARPANET. Almost every operating system includes a Ping program. It has become one of the most versatile and widely used diagnostic tools on the Internet.

ICMP/Ping sends a small packet of information containing an ICMP ECHO_REQUEST to a specified computer, which then sends an ECHO_REPLY packet in return.

You can use Ping to perform several useful network diagnostics, such as the following:

The Network Component Icmp object enables you to add Icmp/Ping functionality to your program, and features the following:

The Icmp object is part of the Network Component. Overview of all Network Component objects:

DnsServer & DnsRecord - Ftp & FtpFile - Http - Icmp - IPtoCountry - Msn - Ntp - Radius - Rsh - Scp - SFtp - Ssh - SnmpManager - SnmpTrapManager - SnmpMibBrowser - Tcp - Tftp - TraceRoute - Udp - Xen - Wake-on-LAN - Xen (Citrix)


Icmp Sample code

VBScript sample: ping a remote host

' Constants: Some Error codes 
Const asERR_SUCCESS=0
  
Set icmpObj = CreateObject("AxNetwork.Icmp")
  
Do
 strHost = inputbox( "Enter host", "Input", "192.168.1.10" )
Loop until strHost <> ""
  
icmpObj.Ping strHost, 2000 ' Timeout 2000 ms
If( icmpObj.LastError = 0 ) Then
  WScript.Echo "Duration:" & icmpObj.LastDuration & "ms"
Else
  Script.Echo "Error " & icmpObj.LastError
End If
  
WScript.Echo "Ready."

Visual Basic .NET sample: ping a remote host

' Constants: Some Error codes 
Imports AxNetwork

   Module Module1
      Sub Main()
        Dim objIcmp As IcmpClass = New Icmp
        Dim objConstants As SocketConstants = New SocketConstants
        Dim i As System.Int16
        Dim strHost As String = "www.activexperts.com"
        For i = 1 To 4
            Console.WriteLine("Pinging " & strHost & " ...")
            objIcmp.Ping(strHost, 2000)
            If (objIcmp.LastError = 0) Then
                Console.WriteLine("  Reply from " & strHost)
                Console.WriteLine("  Time=" & objIcmp.LastDuration.ToString())
            End If
            System.Threading.Thread.Sleep(1000)
        Next
        Console.WriteLine("Ready.")
       End Sub
   End Module

You can download the full samples here.