I am trying to write a routine to Ping an IP address. It is designed to be in a continuous loop so I can jiggle network connections and wires to isolate an occasional communication problem that occurs from time to time (due to, I think, a vibration problem).
The GetRTTAndHopCount call I am using is not working as I think it should. I have a valid address and a normal ping works with the address. The code is written in VB.NET 2003. If there is another method (including a way to specify the record length of the ping, I would appreciate it).
Below is the code I am using:
Public Sub TestLoop()
Dim lIPadr As Long
Dim lHopsCount As Long
Dim lRTT As Long
Dim lMaxHops As Long = 20
Dim lResult As Long
Dim attempts As Long
Dim failures As Long
Dim IPAddress As String = "192.168.1.3"
lIPadr = inet_addr(IPAddress)
If lIPadr > 0 Then
Try
attempts = 0
failures = 0
status = 1
While (status)
lResult = GetRTTAndHopCount(lIPadr, lHopsCount, lMaxHops, lRTT)
If lResult <> 1 Then
failures = failures + 1
Beep()
End If
attempts = attempts + 1
End While
MsgBox("End Test, " & attempts & " attempts (" & failures & " failures)")
Catch ex As Exception
End Try
Else
MsgBox("Invalid IP Address", MsgBoxStyle.Critical)
End If
End Sub
The GetRTTAndHopCount call I am using is not working as I think it should. I have a valid address and a normal ping works with the address. The code is written in VB.NET 2003. If there is another method (including a way to specify the record length of the ping, I would appreciate it).
Below is the code I am using:
Public Sub TestLoop()
Dim lIPadr As Long
Dim lHopsCount As Long
Dim lRTT As Long
Dim lMaxHops As Long = 20
Dim lResult As Long
Dim attempts As Long
Dim failures As Long
Dim IPAddress As String = "192.168.1.3"
lIPadr = inet_addr(IPAddress)
If lIPadr > 0 Then
Try
attempts = 0
failures = 0
status = 1
While (status)
lResult = GetRTTAndHopCount(lIPadr, lHopsCount, lMaxHops, lRTT)
If lResult <> 1 Then
failures = failures + 1
Beep()
End If
attempts = attempts + 1
End While
MsgBox("End Test, " & attempts & " attempts (" & failures & " failures)")
Catch ex As Exception
End Try
Else
MsgBox("Invalid IP Address", MsgBoxStyle.Critical)
End If
End Sub