|
-
Jul 15th, 1999, 03:37 AM
#1
Thread Starter
New Member
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.
-
Jul 17th, 1999, 09:30 AM
#2
Are you getting a Division By Zero error when you run your compiled EXE?
Try changing the Project Properties Compile Section to No Optimization and it should work fine, the only thing I can think of is some error trapping is sacrificed for speed when the compiled code is optimized.
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
-
Jul 18th, 1999, 02:31 AM
#3
Thread Starter
New Member
Damn your the man Aaron, and you are right the pinging becomes very very slow. Are there no ways to speed it up like how it works in the Development Environment?
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
|