Results 1 to 12 of 12

Thread: How to check if Network PC is online

  1. #1

    Thread Starter
    Addicted Member bulletrick's Avatar
    Join Date
    Jul 2005
    Location
    Philippines
    Posts
    248

    Question How to check if Network PC is online

    Guys, how do I check if a PC connected to a network is online?

    I created a program that will distribute a file to all IP addresses given.

    My problem is, when the user gives an IP that is offline (turned off or not connected to the network), the program hangs for a few seconds while executing the FileCopy procedure then returns an error that the path can't be found.

    I wanted to prevent the hang up and I think I can do that by checking first if the IP is online before going to the FileCopy procedure.

    Thanks a lot guys!

  2. #2
    Fanatic Member
    Join Date
    May 2005
    Posts
    608

    Re: How to check if Network PC is online

    Ping the IP?
    I do like the reward system. If you find that my post was useful, rate it.

  3. #3

    Thread Starter
    Addicted Member bulletrick's Avatar
    Join Date
    Jul 2005
    Location
    Philippines
    Posts
    248

    Question Re: How to check if Network PC is online

    Quote Originally Posted by HoraShadow
    Ping the IP?
    Good idea.. How do I do that in VB?

  4. #4
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: How to check if Network PC is online

    you could just connect to the IP on port 80. Port 80 will accept connections on most hosts.

    so have a winsock on the form and use this
    VB Code:
    1. Winsock1.Connect strIP, 80

    heres the Winsock Connect sub
    VB Code:
    1. Private Sub Winsock1_Connect()
    2.      'Connected! so the host must be online
    3.      Winsock1.Close 'Disconnect the socket & return to closed state
    4. End Sub
    The winsock error sub
    VB Code:
    1. Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
    2.      'Socket errored so it didnt connect - the host is not online
    3.      Winsock1.Close 'Return its state to closed
    4. End Sub
    Chris

  5. #5

    Thread Starter
    Addicted Member bulletrick's Avatar
    Join Date
    Jul 2005
    Location
    Philippines
    Posts
    248

    Re: How to check if Network PC is online

    the182guy: this works even if the PC don't have a VB program w/ winsock? as long as the PC is connected and online? thanks!

  6. #6
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: How to check if Network PC is online

    Quote Originally Posted by bulletrick
    the182guy: this works even if the PC don't have a VB program w/ winsock? as long as the PC is connected and online? thanks!
    the computer that your trying to find out the online status of does not need any vb app on it.
    Chris

  7. #7

    Thread Starter
    Addicted Member bulletrick's Avatar
    Join Date
    Jul 2005
    Location
    Philippines
    Posts
    248

    Arrow Re: How to check if Network PC is online

    Quote Originally Posted by the182guy
    the computer that your trying to find out the online status of does not need any vb app on it.
    Ok. thanks a lot! That's what I needed. Try it later. Thanks again!

  8. #8
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: How to check if Network PC is online

    Quote Originally Posted by bulletrick
    Ok. thanks a lot! That's what I needed. Try it later. Thanks again!
    alright no probs, post back if you have problems
    Chris

  9. #9

    Thread Starter
    Addicted Member bulletrick's Avatar
    Join Date
    Jul 2005
    Location
    Philippines
    Posts
    248

    Re: How to check if Network PC is online

    Hello 182guy!

    Uhhh.. the code did not work...

  10. #10
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: How to check if Network PC is online

    did you set the IP? you should change the 'strIP' to the network target IP address
    Chris

  11. #11

    Thread Starter
    Addicted Member bulletrick's Avatar
    Join Date
    Jul 2005
    Location
    Philippines
    Posts
    248

    Arrow Re: How to check if Network PC is online

    Quote Originally Posted by the182guy
    did you set the IP? you should change the 'strIP' to the network target IP address
    Hehe. Of course.. I know that. I used "192.0.1.170", 80.

  12. #12
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: How to check if Network PC is online

    you could get the list of connected terminals to the LAN, then you could check the list if the specified terminal is connected, I posted an example on how to do this here:
    http://www.vbforums.com/showthread.php?t=391595
    Chris

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