Given the following code
#!/usr/bin/perl -w
use IO::Socket;
my($handle, $line, $kidpid);
$handle = IO::Socket::INET->new(
PeerAddr =>"64.22.229.139",
PeerPort =>"4321",
Proto=>"tcp",
)
or die "cant connect to port: $!";
$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 = <STDIN>)){
print $handle $line;
}
}
I want it so it can make two simultaneous connections to the server (instead of one). I thought about maybe using multiple forks(), but I'm at a loss at even how to construct the pseudo code. Ideas?
Thanks in advance