■■■

2016年4月3日日曜日

VB.NET:C#でping送信する方法

VB.NET:C#でping送信する方法
VB.NET
Dim p As New System.Net.NetworkInformation.Ping()
Dim reply As System.Net.NetworkInformation.PingReply = p.Send("192.168.100.1")
If reply.Status = System.Net.NetworkInformation.IPStatus.Success Then
Console.WriteLine("Reply from {0}:bytes={1} time={2}ms TTL={3}", _
reply.Address, reply.Buffer.Length, _
reply.RoundtripTime, reply.Options.Ttl)
Else
Console.WriteLine("Ping送信失敗。({0})", reply.Status)
End If

p.Dispose()
C#
System.Net.NetworkInformation.Ping p =
new System.Net.NetworkInformation.Ping();
System.Net.NetworkInformation.PingReply reply = p.Send("www。yahoo.com");
if (reply.Status == System.Net.NetworkInformation.IPStatus.Success)
{
Console.WriteLine("Reply from {0}:bytes={1} time={2}ms TTL={3}",
reply.Address, reply.Buffer.Length,
reply.RoundtripTime, reply.Options.Ttl);
}
else
{
Console.WriteLine("Ping送信失敗。({0})",
reply.Status);
}

p.Dispose();

■■■