C# PingReply类代码示例(c#pingreply类代码示例汇总)

本文整理汇总了C#中System.Net.NetworkInformation.PingReply的典型用法代码示例。如果您正苦于以下问题:C# PingReply类的具体用法?C# PingReply怎么用?C# PingReply使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


C# PingReply类代码示例(c#pingreply类代码示例汇总)

PingReply类属于System.Net.NetworkInformation命名空间,在下文中一共展示了PingReply类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Main

//引入命名空间
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);
            }
        }
    }
}
开发者ID:.NET开发者,项目名称:System.Net.NetworkInformation,代码行数:36,代码来源:PingReply

本文标签属性:

示例:示例英文

代码:代码大全可复制

PingReply:PingReply

上一篇:C# CSharp.FlowBranching类代码示例(c#中mono.csharp.flowbranching典型用法代码示例汇总)
下一篇:Python Timer.cancel方法代码示例(pythontimer.cancel方法的典型用法代码示例)

为您推荐