in reply to Re: Timeout parameter for Net::Telnet under Windows
in thread Timeout parameter for Net::Telnet under Windows

On Windows, alarm() doesn't interrupt system calls, so that's maybe why the timeout isn't working properly.

Replies are listed 'Best First'.
Re^3: Timeout parameter for Net::Telnet under Windows
by SwaJime (Scribe) on Jan 22, 2016 at 16:13 UTC

    I've logged a bug for this at https://rt.cpan.org/Public/Bug/Display.html?id=111370 with this info. Hopefully somebody can come up with a fix or a workaround. I'm having to write some ugly code to get around this in the meantime.

Re^3: Timeout parameter for Net::Telnet under Windows
by VinsWorldcom (Prior) on Jan 22, 2016 at 15:56 UTC

    As I said above "someone smarter than me" - thanks for coming to the rescue Corion!

Re^3: Timeout parameter for Net::Telnet under Windows
by SwaJime (Scribe) on Jan 28, 2016 at 20:56 UTC

    I just found and tried this code, still no luck. It still takes 20 to 30 seconds to regain control. From Chapter 18. The UDP Protocol, in "Network Programming with Perl".

    eval { local $SIG{ALRM} = sub { die "timeout\n" }; alarm(2); $t = new Net::Telnet (Host => $host, Port => $port, Timeout => 1, Prompt => '/Escape character is.+\n/', Rs => ' ', Ors => '', Binmode => 1, Telnetmode => 1, Errmode => 'return'); alarm(0); }; if ($@) { die $@ unless $@ eq "timeout\n"; warn "Timed out!\n"; }

      I also tried ualarm() from Time::HiRes;

      For that it's even worse. I get "Time::HiRes::ualarm(): unimplemented in this platform"

      *sigh*