ViSi0n
Jul 15th, 1999, 03:37 AM
My sub i'm using is
Public Function Ping(szAddress As String, ECHO As ICMP_ECHO_REPLY) As Long
Dim hPort As Long
Dim dwAddress As Long
Dim sDataToSend As String
Dim iOpt As Long
sDataToSend = " Echo This Echo This Echo This"
dwAddress = AddressStringToLong(szAddress)
Call SocketsInitialize
hPort = IcmpCreateFile()
If IcmpSendEcho(hPort, dwAddress, sDataToSend, Len(sDataToSend), 0, ECHO, Len(ECHO), PING_TIMEOUT) Then
'the ping succeeded,
'.Status will be 0
'.RoundTripTime is the time in ms for
'the ping to complete,
'.Data is the data returned (NULL terminated)
'.Address is the Ip address that actually replied
'.DataSize is the size of the string in .Data
Ping = ECHO.RoundTripTime
Else: Ping = ECHO.status * -1
End If
Call IcmpCloseHandle(hPort)
Call SocketsCleanup
End Function
and my code is:
Dim O As Variant
Dim ECHO As ICMP_ECHO_REPLY
For O = 0 To Openr.List1.ListCount - 1
Openr.List1.ListIndex = O
Openr.StatusBar1.SimpleText = "Pinging: " + Openr.List1
Call Ping(Openr.List1, ECHO)
Openr.Text1 = ECHO.RoundTripTime & " ms"
If Openr.Text1.text = "0 ms" Then Openr.Text1.text = "Timeout"
but it doesn't seem to be pinging, unless i'm in the development environment.
Public Function Ping(szAddress As String, ECHO As ICMP_ECHO_REPLY) As Long
Dim hPort As Long
Dim dwAddress As Long
Dim sDataToSend As String
Dim iOpt As Long
sDataToSend = " Echo This Echo This Echo This"
dwAddress = AddressStringToLong(szAddress)
Call SocketsInitialize
hPort = IcmpCreateFile()
If IcmpSendEcho(hPort, dwAddress, sDataToSend, Len(sDataToSend), 0, ECHO, Len(ECHO), PING_TIMEOUT) Then
'the ping succeeded,
'.Status will be 0
'.RoundTripTime is the time in ms for
'the ping to complete,
'.Data is the data returned (NULL terminated)
'.Address is the Ip address that actually replied
'.DataSize is the size of the string in .Data
Ping = ECHO.RoundTripTime
Else: Ping = ECHO.status * -1
End If
Call IcmpCloseHandle(hPort)
Call SocketsCleanup
End Function
and my code is:
Dim O As Variant
Dim ECHO As ICMP_ECHO_REPLY
For O = 0 To Openr.List1.ListCount - 1
Openr.List1.ListIndex = O
Openr.StatusBar1.SimpleText = "Pinging: " + Openr.List1
Call Ping(Openr.List1, ECHO)
Openr.Text1 = ECHO.RoundTripTime & " ms"
If Openr.Text1.text = "0 ms" Then Openr.Text1.text = "Timeout"
but it doesn't seem to be pinging, unless i'm in the development environment.