From 6f110be148506fb3d86be84e2acba7cf932c58dd Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 11 Jul 2009 00:00:07 -0500 Subject: read off the things the termcast server sends back (sorear++) --- lib/App/Termcast.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/App/Termcast.pm b/lib/App/Termcast.pm index c4345fa..c4bdf1a 100644 --- a/lib/App/Termcast.pm +++ b/lib/App/Termcast.pm @@ -57,6 +57,7 @@ sub run { my $socket = IO::Socket::INET->new(PeerAddr => $self->host, PeerPort => $self->port); $socket->write('hello '.$self->user.' '.$self->password."\n"); + my $sockfd = fileno($socket); my $pty = IO::Pty::Easy->new(raw => 0); $pty->spawn(@argv); @@ -65,6 +66,7 @@ sub run { my ($rin, $rout) = ''; vec($rin, fileno(STDIN) ,1) = 1; vec($rin, $ptyfd, 1) = 1; + vec($rin, $sockfd, 1) = 1; ReadMode 5; while (1) { my $ready = select($rout = $rin, undef, undef, undef); @@ -86,6 +88,15 @@ sub run { syswrite STDOUT, $buf; $socket->write($buf); } + if (vec($rout, $sockfd, 1)) { + my $buf; + $socket->recv($buf, 4096); + if (!defined $buf || length $buf == 0) { + warn "Error reading from socket: $!" unless defined $buf; + last; + } + # XXX: do something with this? (watcher notification, etc) + } } ReadMode 0; } -- cgit v1.2.3-54-g00ecf