IPStatus 列挙体
アセンブリ: System (system.dll 内)
構文Public Enumeration IPStatus
メンバ
解説Ping クラスは、この列挙体の値を使用して、PingReply.Status プロパティを設定します。System.Net.NetworkInformation.Ping.Send メソッドまたは System.Net.NetworkInformation.Ping.SendAsync メソッドを呼び出して、ネットワーク経由でコンピュータに到達できるかどうかを確認すると、Ping クラスは PingReply オブジェクトを返します。
使用例ICMP エコー メッセージを送信し、ステータスを確認するコード例を次に示します。
using System; using System.Net; using System.Net.NetworkInformation; using System.Text; namespace Examples.System.Net.NetworkInformation.PingTest { public class PingExample { // args[0] can be an IPaddress or host name. public static void Main (string[] args) { Ping pingSender = new Ping (); PingOptions options = new PingOptions (); // Use the default Ttl value which is 128, // but change the fragmentation behavior. options.DontFragment = true; // Create a buffer of 32 bytes of data to be transmitted. string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; byte[] buffer = Encoding.ASCII.GetBytes (data); int timeout = 120; PingReply reply = pingSender.Send (args[0], timeout, buffer, options); if (reply.Status == IPStatus.Success) { 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); } } } }
プラットフォームWindows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照- IPStatus 列挙体のページへのリンク