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 ( #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? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2022-05-29 08:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (101 votes). Check out past polls.

    Notices?