How to check Internet Connection in C#

private bool CheckInternetConnection()
        {

            bool _Output = false;
            try
            {
                Ping myPing = new Ping();
                String host = "google.com";
                byte[] buffer = new byte[32];
                int timeout = 1000;
                PingOptions pingOptions = new PingOptions();
                PingReply reply = myPing.Send(host, timeout, buffer, pingOptions);
                if (reply.Status == IPStatus.Success)
                    _Output = true;
                else
                    _Output = false;
            }
            catch (Exception ex) {  }
            return _Output;
        }




Post a Comment

1 Comments

  1. Nowadays landline texting is the best way to communicate and most of the customers also like it. So if you want to get success in your business, then you should use text to landline service for business.

    ReplyDelete