Announcement

Collapse
No announcement yet.

Prototype functions (LoadLibrary revisited)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Prototype functions (LoadLibrary revisited)

    Thanks Jim!
    So Beer and code doesn't mix *Grin*


    Scott

    [This message has been edited by Scott Turchin (edited January 17, 2000).]
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

  • #2
    Scott,

    Did you ever get your PING code working? If so, can you post the complete code or a working sample?

    Thanks!

    --Dave


    -------------
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Home of the BASIC Gurus
    www.basicguru.com

    Comment


    • #3
      Yup, sure did, put a sniffer on the wire and all and it looks good.
      I don't have as much control on it YET in the IP header, I would like to get complete control and set the TLL appropriately but so far it looks good and pings.
      It has one minor bug in it that any good programmer can pull out and test, I found it but haven't fixed it yet, basically it will time out from the TCP/IP Stack andcome back and POST a return in some instances, and then will post the thousands of ms that it waited...


      I'll post it in the source code forum again if need be.
      I may fix this code tonight, got several projects going though, but since I have a sniffer at home now, I can verify the packets on the wire...

      Code:
      Function Ping(DestAddress As Asciiz) As String
      Local Options     As ICMP_OPTIONS
      Local ER          As ICMP_ECHO_REPLY
      Local inetAddr    As in_addr
      Local hPing       As Long
      Local DestinationAddress As Long
      Local RTT         As String
      Local RequestData As Asciiz * 120
      Local RequestSize As Integer
      Local RequestOptions As Long
      
      
      RequestData = CCS
      RequestSize = SizeOf(RequestData)
      RequestOptions = 0
      
      'Open ICMP
      hPing = IcmpCreateFile
      
      'convert haddr to a long
      DestinationAddress = inet_addr(DestAddress)
      
      'Do the ping
      DoEventsApi
      Result = IcmpSendEcho(ByVal hPing, _
                            ByVal DestinationAddress,_
                            RequestData,_
                            ByVal RequestSize,_
                            ByVal RequestOptions,_
                            ER, _
                            SizeOf(ER) + 8, _
                            128)
      
      DoEventsApi
      'Convert IP address from internet IP to string pointer
      inetAddr.s_addr = ER.Address
      ptr1 = inet_ntoa(lpaddr.s_addr)
      WSAErMsg = WSAGetLastError
      If WSAErMsg <> 0 Then
         Function = WSAErMsgToStr(WSAErMsg)
      Else
         If ER.RoundTripTime < 10 Then RTT = " <10" Else RTT = Ltrim$(Str$(ER.RoundTripTime))
         Function = TimeSTamp + " Reply from " + @ptr1 + " time=" + PadString(3, RTT) + "ms TTL=" + Ltrim$(Str$(ER.Options.Ttl))
      End If
      'Close Port
      IcmpCloseHandle hPing
      End Function
      [This message has been edited by Scott Turchin (edited January 17, 2000).]
      Scott Turchin
      MCSE, MCP+I
      http://www.tngbbs.com
      ----------------------
      True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

      Comment


      • #4
        Thanks!

        --Dave


        -------------
        PowerBASIC Support
        mailto:[email protected][email protected]</A>

        Home of the BASIC Gurus
        www.basicguru.com

        Comment


        • #5
          I found a significant bug with this code last night, hence I was up till midnight trying to fix it to no avail I believe.
          On some occasions, the way I do the reverse lookup etc, the ICMPECHO function will return a zero, I do NOT know what that means, it failed but yet I will still get a return...
          So other than:
          1) Error checking needs to be ENTIRELY revisited in this code
          2) Verify if it ECHO'd (Sniffer showed it did)
          3) How do I set up the IP header for TTL on this, it does not take the value's as I change them, it's always at 128 hops...
          Maybe that's a limitation of tcp/ip but I thought y ou could go as high as 254 hops.


          I'm still working on it, and another project, so I'll have it completely updated by tonight or tomorrow, maybe I'll post the entire program code, it's a TAD bit more robust than MS Ping.exe is....I think....




          -------------
          Scott Turchin


          Scott Turchin
          MCSE, MCP+I
          http://www.tngbbs.com
          ----------------------
          True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

          Comment

          Working...
          X