In The Hand LtdIn The Hand
Ping Class
NamespacesInTheHand.Net.NetworkInformationPing
.NET Components for Mobility
Allows an application to determine whether a remote computer is accessible over the network.
Declaration Syntax
C#Visual Basic
public class Ping : Component
Public Class Ping _
	Inherits Component
Members
All MembersConstructorsMethodsPropertiesEvents



IconMemberDescription
Ping()()()()
Initializes a new instance of the Ping class.

CanRaiseEvents
Gets a value indicating whether the component can raise an event.
(Inherited from Component.)
Container
Gets the IContainer that contains the Component.
(Inherited from Component.)
CreateObjRef(Type)
Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
(Inherited from MarshalByRefObject.)
DesignMode
Gets a value that indicates whether the Component is currently in design mode.
(Inherited from Component.)
Dispose(Boolean)
Releases the unmanaged resources used by the Ping and optionally releases the managed resources
(Overrides Component.Dispose(Boolean).)
Dispose()()()()
Releases all resources used by the Component.
(Inherited from Component.)
Disposed
Occurs when the component is disposed by a call to the Dispose()()()() method.
(Inherited from Component.)
Equals(Object)
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Events
Gets the list of event handlers that are attached to this Component.
(Inherited from Component.)
Finalize()()()()
Releases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection.
(Inherited from Component.)
GetHashCode()()()()
Serves as a hash function for a particular type.
(Inherited from Object.)
GetLifetimeService()()()()
Retrieves the current lifetime service object that controls the lifetime policy for this instance.
(Inherited from MarshalByRefObject.)
GetService(Type)
Returns an object that represents a service provided by the Component or by its Container.
(Inherited from Component.)
GetType()()()()
Gets the Type of the current instance.
(Inherited from Object.)
InitializeLifetimeService()()()()
Obtains a lifetime service object to control the lifetime policy for this instance.
(Inherited from MarshalByRefObject.)
MemberwiseClone(Boolean)
Creates a shallow copy of the current MarshalByRefObject object.
(Inherited from MarshalByRefObject.)
MemberwiseClone()()()()
Creates a shallow copy of the current Object.
(Inherited from Object.)
Send(String)
Attempts to send an Internet Control Message Protocol (ICMP) echo message to the specified computer, and receive a corresponding ICMP echo reply message from that computer.

Send(IPAddress)
Attempts to send an Internet Control Message Protocol (ICMP) echo message to the computer that has the specified IPAddress, and receive a corresponding ICMP echo reply message from that computer.

Send(IPAddress, Int32)
Attempts to send an Internet Control Message Protocol (ICMP) echo message with the specified data buffer to the computer that has the specified IPAddress, and receive a corresponding ICMP echo reply message from that computer. This overload allows you to specify a time-out value for the operation.

Send(String, Int32)
Attempts to send an Internet Control Message Protocol (ICMP) echo message to the specified computer, and receive a corresponding ICMP echo reply message from that computer. This overload allows you to specify a time-out value for the operation.

Send(IPAddress, Int32, array<Byte>[]()[][])
Attempts to send an Internet Control Message Protocol (ICMP) echo message with the specified data buffer to the computer that has the specified IPAddress, and receive a corresponding ICMP echo reply message from that computer. This overload allows you to specify a time-out value for the operation.

Send(String, Int32, array<Byte>[]()[][])
Attempts to send an Internet Control Message Protocol (ICMP) echo message with the specified data buffer to the specified computer, and receive a corresponding ICMP echo reply message from that computer. This overload allows you to specify a time-out value for the operation.

Send(IPAddress, Int32, array<Byte>[]()[][], PingOptions)
Attempts to send an Internet Control Message Protocol (ICMP) echo message with the specified data buffer to the computer that has the specified IPAddress and receive a corresponding ICMP echo reply message from that computer. This overload allows you to specify a time-out value for the operation and control fragmentation and Time-to-Live values for the ICMP echo message packet.

Send(String, Int32, array<Byte>[]()[][], PingOptions)
Attempts to send an Internet Control Message Protocol (ICMP) echo message with the specified data buffer to the specified computer, and receive a corresponding ICMP echo reply message from that computer. This overload allows you to specify a time-out value for the operation and control fragmentation and Time-to-Live values for the ICMP packet.

Site
Gets or sets the ISite of the Component.
(Inherited from Component.)
ToString()()()()
Returns a String containing the name of the Component, if any. This method should not be overridden.
(Inherited from Component.)
Remarks
Applications use the Ping class to detect whether a remote computer is reachable.

Network topology can determine whether Ping can successfully contact a remote host. The presence and configuration of proxies, network address translation (NAT) equipment, or firewalls can prevent Ping from succeeding. A successful Ping indicates only that the remote host can be reached on the network; the presence of higher level services (such as a Web server) on the remote host is not guaranteed.

The Send(String) method send an Internet Control Message Protocol (ICMP) echo request message to a remote computer and waits for an ICMP echo reply message from that computer. For a detailed description of ICMP messages, see RFC 792, available at http://www.ietf.org.
Platforms Supported
Windows Mobile
Windows Mobile Version 5.0 and later
Windows Embedded Compact
Windows CE .NET 4.0 and later
Examples
The following code example demonstrates using the Ping class.
CopyC#
using System;
using System.Net;
using InTheHand.Net.NetworkInformation;
using System.Text;

namespace Examples.InTheHand.Net.NetworkInformation.PingTest
{
    public class PingExample
    {
        // args[0] can be an IPaddress or host name.
        public static void Main (string[] args)
        {
            Ping pingSender = new Ping ();
            PingOptions options = new PingOptions ();
            // change the fragmentation behavior.
            options.DontFragment = true;

            // Create a buffer of 32 bytes of data to be transmitted.
            string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
            byte[] buffer = Encoding.ASCII.GetBytes (data);
            int timeout = 120;
            PingReply reply = pingSender.Send (args[0], timeout, buffer, options);
            if (reply.Status == IPStatus.Success)
            {
                string message = string.Format("Address: {0}\r\nRoundTrip time: {1}\r\nTime to live: {2}\r\nDon't fragment: {3}\r\nBuffer size: {0}",
                    reply.Address.ToString(),
                    reply.RoundtripTime,
                    reply.Options.Ttl,
                    reply.Options.DontFragment,
                    reply.Buffer.Length);
                MessageBox.Show(message, "Ping");
            }
            else
            {
                MessageBox.Show(reply.Status.ToString(), "Ping");
            }
        }
    }
}
Inheritance Hierarchy

Assembly: InTheHand.Net (Module: InTheHand.Net) Version: 7.0.0.0