-3

リモートサーバーでインターネット接続をテストする C# コードを書くことは可能ですか?

たとえば、powerhsell を使用してこれを行う場合、次のようにします。

Psexec \\MyWebServer ping www.google.com

ありがとう

4

1 に答える 1

1

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);
    }

詳細はこちら

于 2013-05-24T11:35:05.947 に答える