Results 1 to 3 of 3

Thread: Pinging not working plz help

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 1999
    Posts
    6

    Post

    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.

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    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]

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 1999
    Posts
    6

    Post

    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
  •  



Click Here to Expand Forum to Full Width