Results 1 to 8 of 8

Thread: How to detect when the client is back online

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Posts
    6

    How to detect when the client is back online

    The application that I am trying to build basically try to do this:
    Each time the user updates a record, the app will check to see if the machine is online (LAN, internet, etc). If it is online, it will send the record to the server, if it is not online, then it will save it locally and when the user goes online, it will send the record to the server.
    So I am thinking to send the data to the server. If that fails, then I can assume that the user is offline or the server is down, which is the same in my situation. Now the main problem is how to know when the user is back online. There must be a system event that gets fired when you go online. I am trying to know the name of that event and how to use it. I appreciate your help.

  2. #2
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    VB Code:
    1. Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpSFlags As Long, ByVal dwReserved As Long) As Long
    2.  
    3. If InternetGetConnectedState(0, 0) Then
    4.  
    5.     MsgBox "Online"
    6.  
    7. Else
    8.  
    9.     MsgBox "Offline"
    10.  
    11. End If
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Posts
    6
    So do I need to call "InternetGetConnectedState" all the time in order to know when the machine is back online?

  4. #4
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    My idea would be to check when database is to be updated.

    If online update as such.

    If offline, update locally.

    When application is started, check to see if connected, if so , update the main database form the local copy...
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  5. #5

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Posts
    6
    Thanks James. I tried your code and it works. I am using windows XP. Do you know if most windows versions have "wininet.dll" ?

  6. #6
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    Good question. I mainly develop for NT/2000 client so I couldn't answer. Perhaps try posting in the General Vb Questions area?

    Glad I could help (sort of )
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  7. #7
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    Did you reslove this issue?
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  8. #8

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Posts
    6
    I didn’t have the time to work on it but I will post to the issue on general discusion for VB.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width