#!/usr/bin/perl use strict; use IO::Socket::INET; use IO::Multiplex; $| = 1; my $mux = new IO::Multiplex; my $sock = IO::Socket::INET->new(PeerAddr => 'vortex.labs.pulltheplug.org', PeerPort => '5842', Proto => 'tcp'); my $tot = 0; my $num = 0; my $upack = "IIII"; $mux->add($sock); $mux->set_callback_object(__PACKAGE__); # Enter the main mux loop. $mux->loop; sub mux_close { my $self = shift; print "closed."; } sub mux_input { my $package = shift; my $mux = shift; my $fh = shift; my $input = shift; my @array = unpack( $upack , $$input ); foreach ( @array ) { print "$_\n"; $tot += $_; } $num++; if ( $num == 2 ) { print "sending : $tot\n"; $mux->write($fh, "$tot\n"); $upack = "aaaa"; } # Figure out whence the input came, and send it on to the # other place. # if ($fh == $sock) { # print STDOUT $$input; # } # else { # print $sock $$input; # } # Remove the input from the input buffer. $$input = ''; close FILE; }