rockmountain has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use IO::Socket; use Net::Ping; $sock = new IO::Socket::INET (LocalHost => 'xxx.xxx.xxx.xxx', LocalPor +t => 9321, Proto => 'tcp', Listen => 5, Reuse => 1 ); die "Socket could not be created. Reason: $!" unless $sock; $reach = Net::Ping->new($ > ? "tcp": "icmp"); (defined $reach) or die "Couldn't create Net::Ping object: $!\n"; while ($new_sock = $sock->accept()) { while (defined ($buf = <$new_sock>)) { print $buf; $host = (split(/:/,$buf))1; print "$host"; if($reach->ping("$host")) { print "host is reachable"; } else { print "host is unreachable"; } } }#end of 1st while loop close ($sock);
Cheers,#!/usr/bin/perl use IO::Socket; use Net::Ping; $destination = '198.148.129.182'; $sock = new IO::Socket::INET (PeerAddr => '172.30.166.234', PeerPort = +> 9321, Proto => 'tcp', ); die "Socket could not be created. Reason: $!\n" unless $sock; print $sock "ping:$destination \n"; close ($sock);
Edited by planetscape - added code tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Ping from remote host which is a Windows server
by Solo (Deacon) on Jun 13, 2006 at 15:44 UTC | |
|
Re: Ping from remote host which is a Windows server
by jesuashok (Curate) on Jun 13, 2006 at 12:45 UTC | |
by rockmountain (Sexton) on Jun 13, 2006 at 13:23 UTC | |
by jesuashok (Curate) on Jun 13, 2006 at 13:31 UTC |