summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2009-07-11 00:00:07 -0500
committerJesse Luehrs <doy@tozt.net>2009-07-11 00:00:07 -0500
commit6f110be148506fb3d86be84e2acba7cf932c58dd (patch)
tree025f77bd945aeda0f5fce2c9492b397a9565e403
parent79f937d9b0e08bd63c05a1fb0d7e0dabb0b63f8b (diff)
downloadapp-termcast-6f110be148506fb3d86be84e2acba7cf932c58dd.tar.gz
app-termcast-6f110be148506fb3d86be84e2acba7cf932c58dd.zip
read off the things the termcast server sends back (sorear++)
-rw-r--r--lib/App/Termcast.pm11
1 files changed, 11 insertions, 0 deletions
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;
}