リモートサーバーでインターネット接続をテストする C# コードを書くことは可能ですか?
たとえば、powerhsell を使用してこれを行う場合、次のようにします。
Psexec \\MyWebServer ping www.google.com
ありがとう
リモートサーバーでインターネット接続をテストする C# コードを書くことは可能ですか?
たとえば、powerhsell を使用してこれを行う場合、次のようにします。
Psexec \\MyWebServer ping www.google.com
ありがとう
PingおよびPingReplyクラスを使用して、以下System.Net.NetworkInformation
を確認できます。
Ping ping = new Ping();
//PingReply reply= ping.Send("ip address");
PingReply reply= ping.Send("www.google.com");
if(reply.Status == IPStatus.Success)
{
// Connected
Console.WriteLine ("Address: {0}", reply.Address.ToString ());
Console.WriteLine ("RoundTrip time: {0}", reply.RoundtripTime);
Console.WriteLine ("Time to live: {0}", reply.Options.Ttl);
Console.WriteLine ("Don't fragment: {0}", reply.Options.DontFragment);
Console.WriteLine ("Buffer size: {0}", reply.Buffer.Length);
}
else
{
Console.WriteLine (reply.Status);
}
詳細はこちら