How to check if an internet connection is available or not in C #

I developed software for the company. For some licensing purpose, I use a remote database to allow / deny the use of software. This task applies every time a user enters the software. If the Internet connection does not exist or the request to the remote database fails, the user receives an error message and he cannot log into the software and display the http address of the remote database (which I do not want to see if he carefully reads the error)

What I want to know is any way to perform the same procedure, but if the remote database request fails or the Internet connection is unavailable, it should bypass the check for a while, and at the next login, try to perform the same procedure followed. So my client should not know about this licensing.

How to check the Internet connection (LAN, WiFi, Dialup or something else that the user uses) before making a request to the remote database.

Suggested methods:

Regarding the results that I have achieved from Michelleโ€™s question, there is no stable solution.

+4
source share
4 answers

Why not just try a very cheap database query? In fact, you can create a stored procedure just for this purpose - it can even return some version information, etc.

In the end, it is not important whether ping works or whether the client can go to other computers: it is important whether you can talk to the database or not. So check this out.

As for what error message is presented to the user - of course, that is under your control, so make sure that you provide the relevant information.

+7
source
+1
source

I'm not sure if I will try to open a connection with your server and get an exception without visible feedback, whether it will work in C # or not, but are you sure you want to use this method to solve licensing issues? It seems to me that this is not only very easy to detect (for example, a personal firewall will mark the connection), it is also very easy to defeat.

Also, what happens if the user's computer is not connected to the Internet? It is unlikely that I know, but it can happen, and your licensing scheme will be defeated without any conscious effort in the user part.

+1
source
0
source

All Articles