diff options
author | Jesse Luehrs <doy@tozt.net> | 2009-07-11 00:00:07 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2009-07-11 00:00:07 -0500 |
commit | 6f110be148506fb3d86be84e2acba7cf932c58dd (patch) | |
tree | 025f77bd945aeda0f5fce2c9492b397a9565e403 /lib | |
parent | 79f937d9b0e08bd63c05a1fb0d7e0dabb0b63f8b (diff) | |
download | app-termcast-6f110be148506fb3d86be84e2acba7cf932c58dd.tar.gz app-termcast-6f110be148506fb3d86be84e2acba7cf932c58dd.zip |
read off the things the termcast server sends back (sorear++)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/App/Termcast.pm | 11 |
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; } |