diff options
author | Jesse Luehrs <doy@tozt.net> | 2010-01-02 16:45:05 -0600 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2010-01-02 16:45:05 -0600 |
commit | a962e12744c914cc2c0fc12d224bde5fd67ca432 (patch) | |
tree | f25daae3ac41acdd3b81ec926dab727e561f7da9 /lib/IO | |
parent | 4e3cb2795f924508fc5a3e3ebf455cbe1919879b (diff) | |
download | io-socket-telnet-halfduplex-master.tar.gz io-socket-telnet-halfduplex-master.zip |
Diffstat (limited to 'lib/IO')
-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; } |