diff options
Diffstat (limited to 'lib/IO/Socket/Telnet/HalfDuplex.pm')
-rw-r--r-- | lib/IO/Socket/Telnet/HalfDuplex.pm | 10 |
1 files changed, 6 insertions, 4 deletions
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; } |