Results 1 to 8 of 8

Thread: Multiple PINGs in parallel

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Posts
    67

    Multiple PINGs in parallel

    Hello!

    I have a ping function like s = Ping("1.2.3.4", 10000) that returns whether a host is alive or not.
    10000=timeout value in miliseconds

    The ping function uses IcmpSendEcho API function.

    I want to be able to do multiple pings in parallel, even in case the host is not answering ( during the timeout period ).

    I googled and tried using CreateThread API, but it crashes.

    Any idea on how to call my ping function asynchronous or other workaround?

  2. #2
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Multiple PINGs in parallel

    Quote Originally Posted by sorinn View Post
    I want to be able to do multiple pings in parallel, even in case the host is not answering ( during the timeout period ).
    Why exactly do you need to do that?

    Quote Originally Posted by sorinn View Post
    I googled and tried using CreateThread API, but it crashes.

    Any idea on how to call my ping function asynchronous or other workaround?
    Creating additional threads won't be necessary. The remarks in IcmpSendEcho's documentation states:

    Quote Originally Posted by MSDN
    The IcmpSendEcho2 and IcmpSendEcho2Ex functions are enhanced version of IcmpSendEcho that support asynchronous operation. The IcmpSendEcho2Ex function also allows the source IP address to be specified. This feature is useful on computers with multiple network interfaces.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Posts
    67

    Re: Multiple PINGs in parallel

    It is a project I'm working on that shall monitor some IPs at the same time and send an alert if any IP or more IPs are down.

    I don't know how to use IcmpSendEcho2. I guess it is the API that supports IPv6.
    If I keep the same params and I call IcmpSendEcho2, it crashes

  4. #4
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Multiple PINGs in parallel

    Quote Originally Posted by sorinn View Post
    I don't know how to use IcmpSendEcho2. I guess it is the API that supports IPv6.
    No, there are separate APIs for that. This is from the IcmpSendEcho function:

    Quote Originally Posted by MSDN
    For IPv6, use the Icmp6CreateFile, Icmp6SendEcho2, and Icmp6ParseReplies functions.
    Quote Originally Posted by sorinn View Post
    If I keep the same params and I call IcmpSendEcho2, it crashes
    See the previously given documentation link. It contains detailed information about the IcmpSendEcho2 function and instructions on how to pass each parameter.
    Last edited by Bonnie West; Apr 3rd, 2013 at 03:06 PM.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Multiple PINGs in parallel

    One problem with this thread is that the result is all too easily exploited for nefarious purposes such as port scanning. That could make it a prohibited topic and a thread likely to be locked as violating posting guidelines here.

    Of course anyone with any sense has pings disabled anyway, if only at their Internet gateway router.

    Within a LAN there are more reliable ways to detect whether machines are up anyway. But all of this falls into the realm of administrative activities and not VB6 development at all. VB6 is not an admin tool.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Posts
    67

    Re: Multiple PINGs in parallel

    Hello Dilettante!

    My project is to monitor some critical IPs in the organization, IPs given in a file list and send alert via e-mail if smth occurs.
    The computer where this VB6 app will run will have redundant Internet connection using NIC Teaming.

    "Within a LAN there are more reliable ways to detect whether machines are up anyway"...Any effective way to achive my goal with other tools?

  7. #7
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Multiple PINGs in parallel

    Quote Originally Posted by dilettante View Post
    One problem with this thread is that the result is all too easily exploited for nefarious purposes such as port scanning. That could make it a prohibited topic and a thread likely to be locked as violating posting guidelines here.

    Of course anyone with any sense has pings disabled anyway, if only at their Internet gateway router.
    You can't really use the ICMP protocol for port scanning since it doesn't use ports. You can abuse the ICMP protocol by sending large packages of information and by doing so could create a DOS attack, that's why many turn it off on the server. But on the other hand you can abuse the TCP or UDP protocols as well but we have always allowed questions about how to use these.

    Quote Originally Posted by dilettante View Post
    But all of this falls into the realm of administrative activities and not VB6 development at all. VB6 is not an admin tool.
    That's true but no programming language are really admin tools (unless you count things like PowerShell scripts a programming language) yet all software admin tools are built using one programming language or another.

    This thread has been reported, and as always we thank our members for their help on keeping this forum clean, however in this case I will allow it.

  8. #8
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Multiple PINGs in parallel

    You're correct, "port scanning" was the wrong phrase.

Tags for this Thread

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