#THE CLIENT use strict; use IO::Socket; my ($host, $port, $kidpid, $handle, $line); $handle = IO::Socket::INET->new( PeerAddr => "localhost", Proto => 'tcp', PeerPort => "6941") or die "can't connect to port 6941 on host localhost: $!"; print STDERR "[Connected to host:6941]\n"; $handle->autoflush(1); die "can't fork: $!" unless defined($kidpid = fork()); if ($kidpid) { while (defined ($line = <$handle>)) { print STDOUT $line; } kill("TERM", $kidpid); } else { while (defined ($line = )) { print $handle $line; } }