in reply to Non-blocking pings on Win32
use strict; use threads; use Thread::Queue; use Net::Ping; my $ThreadCount = 6; my @Threads; my $ServerQueue = Thread::Queue->new; # my @Servers = whatever foreach my $Item (@Servers) { $ServerQueue->enqueue($Item); } for (1..$ThreadCount) { my $Thread = threads->new(\&Process, $ServerQueue); push (@Threads, $Thread); } foreach my $Thread (@Threads) { $Thread->join(); } sub Process { my $ServerQueue = shift; my $pingobj = Net::Ping->new("icmp",5,64); while (1) { my $Server = $ServerQueue->dequeue_nb(); last if (! $Server); if ($pingobj->ping($Server)) { #ping was good } else { #ping was bad } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Non-blocking pings on Win32
by TheFluffyOne (Beadle) on Nov 25, 2003 at 18:47 UTC | |
|
Re: Re: Non-blocking pings on Win32
by NetWallah (Canon) on Nov 26, 2003 at 06:10 UTC | |
by TheFluffyOne (Beadle) on Nov 26, 2003 at 14:45 UTC | |
by meetraz (Hermit) on Dec 01, 2003 at 21:30 UTC | |
by Ninthwave (Chaplain) on Dec 12, 2003 at 12:00 UTC | |
by meetraz (Hermit) on Dec 15, 2003 at 20:32 UTC | |
by Ninthwave (Chaplain) on Jan 13, 2004 at 10:03 UTC | |
|
Re: Re: Non-blocking pings on Win32
by Ninthwave (Chaplain) on Nov 25, 2003 at 22:20 UTC |