VB.NET 2005 "PING"

gnappi

Member
Joined
Mar 7, 2006
Messages
13
I downloaded the VB 2005 express edition and went right to work checking out the MY namespace for networks.

The My.Computer.Network.IsAvailable

returns an expected true, so hooking up to the newtork I went about making an applet to ping machines on my network.

All appeared to be OK, I can ping with network AND machine up and connected, it seems to work fine. Disconnect the network, still fine. BUT shutting off the target machine STILL doesnt generate any error.

Heres the code from MSDN:

If My.Computer.Network.Ping("198.01.01.01") Then
MsgBox("Server pinged successfully.")
Else
MsgBox("Ping request timed out.")
End If

I presume that the method is determining that a return did occur.

When I PING from the command line, I get the correct "Request Timed Out"
response. I think their method has a bug. Has anyone else used this method with success?


Regards,

Gary
 
Never used the Ping from the My namespace - Ive always used the Ping class directly. Have you tried specifying a timeout value though?
Code:
If My.Computer.Network.Ping("198.01.01.01",30000) Then
    MessageBox.Show("Server pinged successfully.")
Else
    MessageBox.Show("Ping request timed out.")
End If
 
PlausiblyDamp said:
Never used the Ping from the My namespace - Ive always used the Ping class directly. Have you tried specifying a timeout value though?
Code:
If My.Computer.Network.Ping("198.01.01.01",30000) Then
    MessageBox.Show("Server pinged successfully.")
Else
    MessageBox.Show("Ping request timed out.")
End If

The default (IIRC) is 500 milliseconds, pretty tight. I would imagine that the default would cause a false FAILURE rather than a false pass. If that was the case, then setting a longer timeout "should" allow a pass where it wouldnt pass with the default.
 
Back
Top