• C# 测试网络速度例子


    using System.Net.NetworkInformation;  
    namespace PingExample
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void btn_StartPing_Click(object sender, EventArgs e)
            {
                this.lst_PingResult.Items.Clear();
                //远程服务器IP
                string ipStr = txt_IPAddress.Text.ToString().Trim();
                //构造Ping实例
                Ping pingSender = new Ping();
                //Ping 选项设置
                PingOptions options = new PingOptions();
                options.DontFragment = true;
                //测试数据
                string data = "test data abcabc";
                byte[] buffer = Encoding.ASCII.GetBytes(data);
                //设置超时时间
                int timeout = 120;
                //调用同步 send 方法发送数据,将返回结果保存至PingReply实例
                PingReply reply = pingSender.Send(ipStr, timeout, buffer, options);
                if (reply.Status == IPStatus.Success)
                {
                    lst_PingResult.Items.Add("答复的主机地址:" + reply.Address.ToString());
                    lst_PingResult.Items.Add("往返时间:" + reply.RoundtripTime);
                    lst_PingResult.Items.Add("生存时间(TTL):" + reply.Options.Ttl);
                    lst_PingResult.Items.Add("是否控制数据包的分段:" + reply.Options.DontFragment);
                    lst_PingResult.Items.Add("缓冲区大小:" + reply.Buffer.Length);
                }
                else
                    lst_PingResult.Items.Add(reply.Status.ToString());
            }
        }
    }
    https://www.cnblogs.com/daming1233/p/6598028.html
  • 相关阅读:
    Apache Beam的特点
    Apache Beam是什么?
    Kudu1.1.0 、 Kudu1.2.0 Kudu1.3.0的版本信息异同比较
    Kudu compaction design
    [转]Oracle trunc()函数的用法
    [转]Charts (Report Builder and SSRS)
    [转]表变量和临时表的比较
    [转]MONTHS_BETWEEN Function
    [转]Grunt 新手一日入门
    [转]Format a ui-grid grid column as currency
  • 原文地址:https://www.cnblogs.com/nnnnnn/p/11207194.html
Copyright © 2020-2023  润新知