![]() |
|
Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: test version of ssh from windowsby stevieb (Canon) |
on Aug 11, 2015 at 15:05 UTC ( #1138178=note: print w/replies, xml ) | Need Help?? |
Wrapping the socket operations within an eval block will help fix both issues. First, if connection is refused, the error will be put into $@ for later processing if you desire. Second, the timeout effect I believe you're after can be achieved with a local alarm signal handler, and setting the number of seconds before the alarm is raised (this error will also be put into $@ if triggered)...
-stevieb ps. Note that in the IO::Socket::INET documentation, all of the parameters start with an upper-case letter (you mistyped 'Proto' and 'Timeout'). I don't know whether that's operationally important or not in this case, but I wanted to point it out. Not using an API according to the documentation can lead to incorrect results.
In Section
Seekers of Perl Wisdom
|
|