• 网络测试


            /// <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) + "
    ";
                };
            }
  • 相关阅读:
    17111 Football team
    Train Problem I (HDU 100题纪念)
    迷宫问题
    图形点扫描
    看病要排队(stl)
    水果
    Prime Ring Problem
    N皇后问题
    2^x mod n = 1
    Queuing
  • 原文地址:https://www.cnblogs.com/lhlong/p/11057802.html
Copyright © 2020-2023  润新知