在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
static void Main(string[] args) { // 主机地址 string targetHost = "bing.com"; string data = "Hello world"; Ping pingSender = new Ping(); PingOptions options = new PingOptions { DontFragment = true }; byte[] buffer = Encoding.ASCII.GetBytes(data); int timeout = 1024; Console.WriteLine($"Pinging {targetHost}"); //PingReply reply = pingSender.Send(targetHost, timeout, buffer, options); PingReply reply = pingSender.Send(targetHost, timeout); if (reply.Status == IPStatus.Success) { Console.WriteLine($"Address: {reply.Address}"); Console.WriteLine($"RoundTrip time: {reply.RoundtripTime}"); Console.WriteLine($"Time to live: {reply.Options.Ttl}"); Console.WriteLine($"Don't fragment: {reply.Options.DontFragment}"); Console.WriteLine($"Buffer size: {reply.Buffer.Length}"); } else { Console.WriteLine(reply.Status); } Console.ReadLine(); }
|
请发表评论