Csharp/C Sharp by API/System.Net.NetworkInformation/PingReply — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 12:11, 26 мая 2010
PingReply.RoundtripTime
using System;
using System.Net.NetworkInformation;
class MainClass {
public static void Main(string[] args) {
using (Ping ping = new Ping()) {
Console.WriteLine("Pinging:");
foreach (string comp in args) {
try {
Console.Write(" {0}...", comp);
PingReply reply = ping.Send(comp, 100);
if (reply.Status == IPStatus.Success) {
Console.WriteLine("Success - IP Address:{0}", reply.Address, reply.RoundtripTime);
} else {
Console.WriteLine(reply.Status);
}
} catch (Exception ex) {
Console.WriteLine("Error ({0})",
ex.InnerException.Message);
}
}
}
}
}
PingReply.Status
using System;
using System.Net.NetworkInformation;
class MainClass {
public static void Main(string[] args) {
using (Ping ping = new Ping()) {
Console.WriteLine("Pinging:");
foreach (string comp in args) {
try {
Console.Write(" {0}...", comp);
PingReply reply = ping.Send(comp, 100);
if (reply.Status == IPStatus.Success) {
Console.WriteLine("Success - IP Address:{0}", reply.Address, reply.RoundtripTime);
} else {
Console.WriteLine(reply.Status);
}
} catch (Exception ex) {
Console.WriteLine("Error ({0})",
ex.InnerException.Message);
}
}
}
}
}