c#实现ping

 public static string PingResult(string ip)
        {
            System.Net.NetworkInformation.Ping p = new System.Net.NetworkInformation.Ping();
            System.Net.NetworkInformation.PingOptions options = new System.Net.NetworkInformation.PingOptions();
            options.DontFragment = true;
            string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
            byte[] buffer = Encoding.ASCII.GetBytes(data);
            //Wait  seconds for a reply.
             int timeout = 1000

            System.Net.NetworkInformation.PingReply reply = p.Send(ip, timeout, buffer, options);
            return reply.Status.ToString();


        }

posted @ 2007-03-21 16:23  kevinLee  阅读(1123)  评论(2编辑  收藏  举报