in reply to Fastest way to determine whether a specific port is open via a Socket

The following should work for you
use strict; use warnings; use IO::Socket::INET; sub connected { my $host = shift; my $tcp_port = shift; my $sock = IO::Socket::INET ->new( Timeout => 2, PeerAddr => $host, PeerPort => $tcp_port, Proto => 'tcp' ); return $sock ? 0 : 1; }
Ted
--
"That which we persist in doing becomes easier, not that the task itself has become easier, but that our ability to perform it has improved."
  --Ralph Waldo Emerson
  • Comment on Re: Fastest way to determine whether a specific port is open via a Socket
  • Download Code