使用Ping测试网络连通状态

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用Ping测试网络连通状态相关的知识,希望对你有一定的参考价值。

技术分享
   public bool IsPingOk 
        {
            get 
            {
                try
                {
                    Ping ping = new Ping();
                    string ipaddress = this.GetIP(AppConfig.AddrHisService);
                    PingReply pr = ping.Send(ipaddress);
                    if (pr.Status == IPStatus.Success)
                        return true;
                    else
                        return false;
                }
                catch
                {
                    return false;
                }
            }
        }
View Code

 

以上是关于使用Ping测试网络连通状态的主要内容,如果未能解决你的问题,请参考以下文章