Massyn has asked for the wisdom of the Perl Monks concerning the following question:
#!/fellow/monks.pl
I have the following procedure that I use to determine if a TCP port is available. When it's up, it works fine, however, I found that when a link goes down, it takes a while to timeout, resulting in my script to sit and wait a long time before continuing. Is there any way I can force a timeout?
use IO::Socket; sub check_port { my ($host,$port) = @_; $remote = IO::Socket::INET -> new ( Proto => "tcp", PeerAddr => $host, PeerPort => $port ) ; if ($remote) { close $remote; return 1; } else { return 0; } }
Thanks!
#!/massyn.pl The early worm gets caught by the bird.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: TCP port check time out?
by bronto (Priest) on Mar 12, 2003 at 10:31 UTC | |
|
Re: TCP port check time out?
by Tomte (Priest) on Mar 12, 2003 at 10:34 UTC |