Ping class

Performs an ICMP ping to the specified host and measures the time or returns an error message.

Archived content: This source code is currently inactive and may be outdated or no longer maintained or functional.

Mit einem Ping lässt sich feststellen, ob ein anderer Rechner im Netzwerk verfügbar ist. Jedes aktuelle Betriebssystem stellt dafür ein Hilfsprogramm bereit. Diese Funktion lässt sich mit der Ping-Klasse auch direkt aus Anwendungen heraus nutzen.

Hinweis: Diese Klasse wurde nur mit IPv4-Netzwerken getestet. Mit IPv6 funktioniert das so nicht.

Compatibility: .NET Version 2.0 or newer

Beispiel

Der folgende Beispielcode zeigt, wie die Ping-Klasse verwendet werden kann:

label1.Text = "Waiting...";
Ping p = new Ping();
p.Host = "unclassified.software";
p.PingHost();
if (p.Reason == Ping.Reasons.NoError)
{
    label1.Text = p.Time + " ms";
}
else
{
    label1.Text = Ping.ReasonToString(p.Reason);
}

Download

Ping.cs9.7 KiBQuelltext der Ping-Klasse

Licence and terms of use

This software is released under the terms of the simplified BSD licence. You can find the detailed terms and conditions in the download.

Statistic data

  • Created on 2006-04-28, updated on 2007-04-02.
  • Ca. 160 lines of code, estimated development costs: 160 - 640 €