diff options
author | Jesse Luehrs <doy@tozt.net> | 2010-03-27 21:11:21 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2010-03-27 21:11:21 -0500 |
commit | 376a2274ddcf20d61d1f4f5fcdd07e0b8b8e9be2 (patch) | |
tree | dde35b9cac254980ec07e40b251f4cf496b25c2f /lib/App/Termcast.pm | |
parent | 50c996238c6a48bb3a2d666d6ffd6b3eb44cdbd4 (diff) | |
download | app-termcast-376a2274ddcf20d61d1f4f5fcdd07e0b8b8e9be2.tar.gz app-termcast-376a2274ddcf20d61d1f4f5fcdd07e0b8b8e9be2.zip |
try to catch more instances of disconnects
Diffstat (limited to 'lib/App/Termcast.pm')
-rw-r--r-- | lib/App/Termcast.pm | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/App/Termcast.pm b/lib/App/Termcast.pm index da24a7c..f99ecc4 100644 --- a/lib/App/Termcast.pm +++ b/lib/App/Termcast.pm @@ -100,11 +100,20 @@ sub run { vec($rin, $sockfd, 1) = 1; my ($win, $wout) = ''; vec($win, $sockfd, 1) = 1; + my ($ein, $eout) = ''; + vec($ein, $sockfd, 1) = 1; ReadMode 5; my $guard = Scope::Guard->new(sub { ReadMode 0 }); local $SIG{WINCH} = sub { $self->_got_winch(1) }; while (1) { - my $ready = select($rout = $rin, undef, undef, undef); + my $ready = select($rout = $rin, undef, $eout = $ein, undef); + if (vec($eout, $sockfd, 1)) { + Carp::carp("Lost connection to server ($!), reconnecting..."); + $socket = $self->connect; + vec($rin, $sockfd, 1) = 0; + $sockfd = fileno($socket); + vec($rin, $sockfd, 1) = 1; + } if (vec($rout, fileno(STDIN), 1)) { my $buf; sysread STDIN, $buf, 4096; |