Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Fastest way to determine whether a specific port is open via a Socket

by tcf03 (Deacon)
on Oct 30, 2006 at 20:30 UTC ( [id://581373]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://581373]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-05-22 01:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found