Allows an application to determine whether a remote computer is accessible over the network.
| All Members | Constructors | Methods | Properties | Events | |
| Icon | Member | Description |
|---|---|---|
| Ping()()() |
Initializes a new instance of the Ping class.
| |
| Dispose(Boolean) | ||
| Dispose()()() | Releases all resources used by the Component. (Inherited from Component.) | |
| Disposed | Adds an event handler to listen to the Disposed event on the component. (Inherited from Component.) | |
| Equals(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. GetHashCode()()() is suitable for use in hashing algorithms and data structures like a hash table. (Inherited from Object.) | |
| GetType()()() | Gets the Type of the current instance. (Inherited from Object.) | |
| 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 | (Inherited from Component.) | |
| ToString()()() | (Inherited from Object.) |
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.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"); } } } }