4

I have developed a software for a company. For some kind of licensing purpose i am using a remote database to allow/disallow usage of the software. This task is applied every time the user logs into the software. If the internet connection does not exist or the query to the remote database fails, the user gets an error and he can not log into the software and shows the remote database http address (which i dont want him to see, if he carefully read the error)

What i want to know is any way of doing the same procedure, but if the remote database query fails or internet connection is not available, it should bypass the check for the time being, and upon next login try, same procedure is followed. So that my client should not know about this licensing stuff.

How to check the internet connectivity (LAN, WiFi, Dialup or whatever the user is using) before creating a query to the remote database.

Proposed methods:

  1. Ping my remote database server IP.

  2. This Question by Michel

Regarding results what i achieved from Michel' question is no stable solution.

Community
  • 1
  • 1
Assad Nazar
  • 1,420
  • 5
  • 20
  • 40
  • Possible duplicate of [How do I check for a network connection?](https://stackoverflow.com/questions/520347/how-do-i-check-for-a-network-connection) – T.Todua Sep 09 '19 at 11:08

4 Answers4

7

Why not just try to perform a very cheap query on the database? Indeed, you could create a stored procedure for exactly this purpose - it might even give some version information back, etc.

After all, the important thing isn't whether a ping works, or whether the client can go to other machines: the important thing is whether you can talk to the database or not. So test exactly that.

As for what error message is presented to the user - surely that's under your control, so make sure you give appropriate information.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
1

try this:

Check Internet Connection

anishMarokey
  • 11,279
  • 2
  • 34
  • 47
1

I'm not sure whether trying to open a connection to your server and catching an exception without visible feedback will work or not in C#, but are you sure you want to use this method to deal with licensing? It strikes me that not only is it very easy to discover (for example a personal firewall will flag the connection) it's also very easy to defeat.

Additionally, what happens if the user's computer isn't connected to the internet? Unlikely, I know, but it can happen, and your licensing scheme is defeated with no conscious effort on the user's part.

kfb
  • 6,252
  • 6
  • 40
  • 51
  • @r_ can you suggest me any easy to use method as well as procedure? Be sure that i dont want to use any third party software for the specified purpose. If i can get some sort of examples too, for that i will be grateful to you... – Assad Nazar Sep 22 '10 at 10:05
  • @boota: it's not my area of expertise so I can't state with any authority what a good solution would be, but at first glance it seems to me that you have the option of either making the database connection required in some way (and the requirement explicit to the user), or to move to a non-network licence check. A quick Google/SO search would bring up some suggestions for this. – kfb Sep 22 '10 at 12:21
0

you can also try this

C# - Check internet connection

kamal
  • 1
  • 1
    Can you elaborate a bit on the contents of the link and how it's relevant to the question? In it's current form, this reads like spam on an old question that already has an accepted answer. – forsvarir Jul 24 '12 at 10:52