使用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

 

posted @ 2017-07-02 08:49  新进社员  阅读(220)  评论(0编辑  收藏  举报