System.Net.NetworkInformation.Ping Class

Allows an application to determine whether a remote computer is accessible over the network.

See Also: Ping Members


[System.MonoTODO("IPv6 support is missing")]
public class Ping : System.ComponentModel.Component, IDisposable


Applications use the System.Net.NetworkInformation.Ping class to detect whether a remote computer is reachable.

Network topology can determine whether System.Net.NetworkInformation.Ping can successfully contact a remote host. The presence and configuration of proxies, network address translation (NAT) equipment, or firewalls can prevent System.Net.NetworkInformation.Ping from succeeding. A successful System.Net.NetworkInformation.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.

This class provides functionality similar to the Ping.exe command line tool. The erload:System.Net.NetworkInformation.Ping.Send and erload:System.Net.NetworkInformation.Ping.SendAsync methods 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 tp://

The following types are used with the System.Net.NetworkInformation.Ping class and are described in detail below.


Defines status codes that describe the outcome of an ICMP echo request message.


Allows you to configure or retrieve the settings that control how many times the request packet can be forwarded (PingOptions.Ttl), and whether it can be fragmented (PingOptions.DontFragment ).


Contains the results of an ICMP echo request.


Thrown if an unrecoverable error occurs.


Contains the data associated with Ping.PingCompleted events, which are raised when a erload:System.Net.NetworkInformation.Ping.SendAsync call completes or is canceled.


The delegate that provides the callback method invoked when a erload:System.Net.NetworkInformation.Ping.SendAsync call completes or is canceled.

The erload:System.Net.NetworkInformation.Ping.Send and erload:System.Net.NetworkInformation.Ping.SendAsync methods return the reply in a System.Net.NetworkInformation.PingReply object. The PingReply.Status property returns an System.Net.NetworkInformation.IPStatus value to indicate the outcome of the request.

When sending the request, you must specify the remote computer. You can do this by providing a host name string, an IP address in string format, or an System.Net.IPAddress object.

You can also specify any of the following types of information:

The System.Net.NetworkInformation.Ping class offers both synchronous and asynchronous methods for sending the request. If your application should block while waiting for a reply, use the erload:System.Net.NetworkInformation.Ping.Send methods; these methods are synchronous. If your application should not block, use the asynchronous erload:System.Net.NetworkInformation.Ping.SendAsync methods. A call to erload:System.Net.NetworkInformation.Ping.SendAsync executes in its own thread that is automatically allocated from the thread pool. When the asynchronous operation completes, it raises the Ping.PingCompleted event. Applications use a System.Net.NetworkInformation.PingCompletedEventHandler delegate to specify the method that is called for Ping.PingCompleted events. You must add a System.Net.NetworkInformation.PingCompletedEventHandler delegate to the event before calling erload:System.Net.NetworkInformation.Ping.SendAsync. The delegate's method receives a System.Net.NetworkInformation.PingCompletedEventArgs object that contains a System.Net.NetworkInformation.PingReply object that describes the result of the erload:System.Net.NetworkInformation.Ping.SendAsync call.

You cannot use the same instance of the System.Net.NetworkInformation.Ping class to generate multiple simultaneous ICMP Echo requests. Calling erload:System.Net.NetworkInformation.Ping.Send while a erload:System.Net.NetworkInformation.Ping.SendAsync call is in progress or calling erload:System.Net.NetworkInformation.Ping.SendAsync multiple times before all previous calls have completed causes an InvalidOperationException.


Namespace: System.Net.NetworkInformation
Assembly: System (in System.dll)
Assembly Versions:,
Since: .NET 2.0