#!/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'); $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; open FILE, ">file.out" or die "couldn;t open a file\n"; print "inside"; print STDOUT $$input; print FILE $$input; # 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; }