标签:主机 同步 测试数据 pst 远程服务器 length 数据 out 保存
/// <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())+"\r\n"; lst_PingResult = lst_PingResult + ("往返时间:" + reply.RoundtripTime) + "\r\n"; lst_PingResult = lst_PingResult + ("生存时间(TTL):" + reply.Options.Ttl) + "\r\n"; lst_PingResult = lst_PingResult + ("是否控制数据包的分段:" + reply.Options.DontFragment) + "\r\n"; lst_PingResult = lst_PingResult + ("缓冲区大小:" + reply.Buffer.Length) + "\r\n"; }; }
标签:主机 同步 测试数据 pst 远程服务器 length 数据 out 保存
原文地址:https://www.cnblogs.com/lhlong/p/11057802.html