diff options
-rw-r--r-- | dist.ini | 1 | ||||
-rw-r--r-- | lib/IO/Socket/Telnet/HalfDuplex.pm | 10 |
2 files changed, 7 insertions, 4 deletions
@@ -9,3 +9,4 @@ abstract = more reliable telnet communication [Prereq] IO::Socket::Telnet = 0 +Try::Tiny = 0 diff --git a/lib/IO/Socket/Telnet/HalfDuplex.pm b/lib/IO/Socket/Telnet/HalfDuplex.pm index 87fb383..85c1e2f 100644 --- a/lib/IO/Socket/Telnet/HalfDuplex.pm +++ b/lib/IO/Socket/Telnet/HalfDuplex.pm @@ -1,7 +1,8 @@ +package IO::Socket::Telnet::HalfDuplex; use strict; use warnings; -package IO::Socket::Telnet::HalfDuplex; use base 'IO::Socket::Telnet'; +use Try::Tiny; =head1 NAME @@ -94,7 +95,7 @@ sub read { $self->do(chr(${*{$self}}{ping_option})); ${*{$self}}{got_pong} = 0; - eval { + try { local $SIG{__DIE__}; while (1) { @@ -106,10 +107,11 @@ sub read { }; die "Disconnected from server: $!" unless $!{EINTR}; } + } + catch { + die $_ if $_ !~ /^got pong\n/; }; - die $@ if $@ !~ /^got pong\n/; - return $buffer; } |