What is the best way to determine if there is a network connection available?
C# – How to check for a network connection
c++networking
Related Question
- C# – How to enumerate an enum
- C# – Catch multiple exceptions at once
- C# – What are the correct version numbers for C#
- C# – Case insensitive ‘Contains(string)’
- C# – How to get a consistent byte representation of strings in C# without manually specifying an encoding
- C# – reason for C#’s reuse of the variable in a foreach
Best Solution
The marked answer is 100% fine, however, there are certain cases when the standard method is fooled by virtual cards (virtual box, ...). It's also often desirable to discard some network interfaces based on their speed (serial ports, modems, ...).
Here is a piece of code that checks for these cases: