in reply to multithreading solution to the below problem

Consider using Net::Ping with the 'syn' protocol (and ->ack()</c> method) to overlap your pings. It's far more efficient than a multithreaded solution, and easier to write.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP PCW
  • Comment on Re: multithreading solution to the below problem

Replies are listed 'Best First'.
Re^2: multithreading solution to the below problem
by rookie8278 (Initiate) on Jun 25, 2009 at 08:31 UTC
    hey there..thanks for ur reply...pardon me for my lack of knowledge on perl, i did not completely get ur answer :-O let me rephrase, if there are IP1,IP2,...IP255 alive machines in a subnet, the current way of doing is, wait for scan of IP1 to complete and then start scan of IP2 and so on,This takes a lot of time to complete the scan, i am looking into ways where i can send a scan request to more than one machine simultaneously, Does your answer cover this..can u please elaborate.

      Have you read Net::Ping? It describes how you can ping multiple hosts without even needing threads. Please just read Net::Ping and ask specific questions after you've done so. The relevant example from the Net::Ping documentation is:

      # Like tcp protocol, but with many hosts $p = Net::Ping->new("syn"); $p->port_number(getservbyname("http", "tcp")); foreach $host (@host_array) { $p->ping($host); } while (($host,$rtt,$ip) = $p->ack) { print "HOST: $host [$ip] ACKed in $rtt seconds.\n"; }
        Thanks Corion