Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- use common::sense;
- use IO::Socket::INET;
- use AnyEvent::Util;
- use List::Util qw(shuffle);
- sub usage {
- printf "Usage: %s <hostaddr> <port> <packs> <request>\n", $0;
- printf " <hostaddr> - Adress to check.\n";
- printf " <port> - Port to check 1-1024(default is 80).\n";
- printf " <request> - Number of requests(default is 10).\n";
- exit;
- }
- my $host = $ARGV[0] || usage;
- my $port = $ARGV[1] || 80;
- my $request = $ARGV[2] || 10;
- my $cv = AE::cv;
- $AnyEvent::Util::MAX_FORKS = 10;
- for (1 .. $request){
- $cv->begin;
- fork_call {
- } sub {
- &connect($port, $host);
- $cv->end;
- };
- $cv->()
- }
- $cv->wait;
- sub connect{
- my $pr = shift;
- my $ht = shift;
- my $ping = IO::Socket::INET->new(
- PeerPort => $pr ,
- PeerAddr => $ht,
- Proto => 'udp',
- LocalAddr => 'localhost',
- Broadcast => 1,
- Type => SOCK_DGRAM
- )
- or die "Can't bind : $@\n";
- my $string = 'a';
- $ping->recv($string,1024);
- print &parseInput($string);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement