0

I am using following code to check if my app is connected to internet

         try
        {
            using (var client = new WebClient()) 
            using (client.OpenRead("http://google.com/generate_204"))
            return true;
        }
        catch
        {
            return false;
        }

I want to check the connectivity of specific network adapter. for example I have two internet connections. one is connected through WiFi and other one through ethernet cable both are from different ISP. I only want to check the connectivity of Ethernet. someone suggested socket.bind(). But I don't know how to use webclint() with socket.bind() kindly help with example

Abbas
  • 9
  • 6
  • The answers to the duplicate show both how to detect if a connection is generally available, and how to iterate over all network cards and check each one's `OperationalStatus`. You can also listen to the NetworkChanged event of each interface to detect when it goes up or down – Panagiotis Kanavos Oct 12 '20 at 13:04
  • The code you posted looks like *parts* of some of the duplicate answers. What is your *real* question? How to detect if *internet* connectivity is available? Are you trying to ask how to *ping* through a specific adapter? Is that why you refer to `socket.bind()`, because it was mentioned in one of those answers? *Explain what you tried in the question itself* don't expect people to guess what you want or what you tried – Panagiotis Kanavos Oct 12 '20 at 13:08
  • In two connected adapters I simply want to know which adapter is connected to the internet and which is not or if both are connected to the internet with coded example,I want a complete coded example not some function name thanks in advance – Abbas Oct 14 '20 at 05:25

0 Answers0