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

2 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
  2. When resolving online problems, whether for business, communication, or leisure, checking an internet connection is frequently the first step. Testing network speed or resetting the router are easy ways to find issues. In a similar vein, MBA essay writers assist students in clearly organizing complicated concepts, guaranteeing that academic material is professionally constructed and conveyed in an efficient and significant manner.

    ReplyDelete