|
-
Feb 28th, 2006, 08:47 PM
#1
Thread Starter
Addicted Member
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!
-
Mar 1st, 2006, 12:42 PM
#2
Re: How to check if Network PC is online
I do like the reward system. If you find that my post was useful, rate it.
-
Mar 1st, 2006, 08:00 PM
#3
Thread Starter
Addicted Member
Re: How to check if Network PC is online
 Originally Posted by HoraShadow
Ping the IP?
Good idea.. How do I do that in VB?
-
Mar 1st, 2006, 09:37 PM
#4
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:
Winsock1.Connect strIP, 80
heres the Winsock Connect sub
VB Code:
Private Sub Winsock1_Connect()
'Connected! so the host must be online
Winsock1.Close 'Disconnect the socket & return to closed state
End Sub
The winsock error sub
VB Code:
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)
'Socket errored so it didnt connect - the host is not online
Winsock1.Close 'Return its state to closed
End Sub
-
Mar 1st, 2006, 09:43 PM
#5
Thread Starter
Addicted Member
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!
-
Mar 1st, 2006, 09:46 PM
#6
Re: How to check if Network PC is online
 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.
-
Mar 1st, 2006, 09:48 PM
#7
Thread Starter
Addicted Member
Re: How to check if Network PC is online
 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!
-
Mar 1st, 2006, 09:53 PM
#8
Re: How to check if Network PC is online
 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
-
Mar 7th, 2006, 01:47 AM
#9
Thread Starter
Addicted Member
Re: How to check if Network PC is online
Hello 182guy!
Uhhh.. the code did not work...
-
Mar 7th, 2006, 03:47 AM
#10
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
-
Mar 7th, 2006, 06:48 AM
#11
Thread Starter
Addicted Member
Re: How to check if Network PC is online
 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.
-
Mar 7th, 2006, 06:16 PM
#12
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|