zoukankan      html  css  js  c++  java
  • 网络测试

            /// <summary>
            /// 网络测试
            /// </summary>
            private void TestNet( )
            { 
                //远程服务器IP
                string ipStr = "192.168.0.8";
                //构造Ping实例
                Ping pingSender = new Ping();
                //Ping 选项设置
                PingOptions options = new PingOptions();
                options.DontFragment = true;
                //测试数据
                string data = "";
                byte[] buffer = Encoding.ASCII.GetBytes(data);
                //设置超时时间
                int timeout = 120;
                //调用同步 send 方法发送数据,将返回结果保存至PingReply实例
                PingReply reply = pingSender.Send(ipStr, timeout, buffer, options);
    
    
                string lst_PingResult = string.Empty;
                if (reply.Status == IPStatus.Success)
                {
                    lst_PingResult = lst_PingResult+ ("答复的主机地址:" + reply.Address.ToString())+"
    ";
                    lst_PingResult = lst_PingResult + ("往返时间:" + reply.RoundtripTime) + "
    ";
                    lst_PingResult = lst_PingResult + ("生存时间(TTL):" + reply.Options.Ttl) + "
    ";
                    lst_PingResult = lst_PingResult + ("是否控制数据包的分段:" + reply.Options.DontFragment) + "
    ";
                    lst_PingResult = lst_PingResult + ("缓冲区大小:" + reply.Buffer.Length) + "
    ";
                };
            }
  • 相关阅读:
    清北学堂2019.7.18 & 清北学堂2019.7.19
    清北学堂2019.7.17
    清北学堂2019.7.16
    清北学堂2019.7.15
    清北学堂2019.7.14
    清北学堂2019.7.13
    【洛谷P1383 高级打字机】
    考试整理
    考试整理
    【洛谷P5018 对称二叉树】
  • 原文地址:https://www.cnblogs.com/lhlong/p/11057802.html
Copyright © 2011-2022 走看看