Skip to content

Instantly share code, notes, and snippets.

@ryochin
Created November 22, 2011 05:24
Show Gist options
  • Save ryochin/1384967 to your computer and use it in GitHub Desktop.
Save ryochin/1384967 to your computer and use it in GitHub Desktop.
Net::Ping in 'syn' mode
#!/usr/bin/perl --
use strict;
use Net::Ping;
my $p = Net::Ping->new("syn");
$p->port_number( scalar getservbyname("http", "tcp") );
$p->hires(1);
my $host = shift @ARGV // "127.0.0.1";
my $timeout = 2; # sec
if( $p->ping( $host, $timeout ) and $p->ack( $host ) ){
warn "ok";
}
else{
warn "not ok";
}
__END__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment