# Creating connection for local program $lsn=new IO::Socket::INET( Proto => 'tcp', LocalPort => 6000, Listen => 1, ); unless(defined $lsn){ print"$0: $!\n"; exit 1; } print"Waiting for local program connection on port 6000\n"; $server=$lsn->accept; $lsn->close; unless(defined $server){ print "$0: Unable to accept incoming connection: $!\n"; exit 1; } # At this point, the script is waiting for a connection from # the local program on port 6000 printf"Connection accepted from %s\n",$server->peerhost; select $server; binmode $server; $stdin=$server; (select)->autoflush(1); # Creating connection for external website $net=new IO::Socket::INET( Proto => 'tcp', PeerAddr => $yog, PeerPort => $yserverport, ); unless(defined($net)){ print "Can't connect!\n"; exit 1; } $net->autoflush(1); #################################### # Here the script and server will # # exchange information few times # #################################### my $sel=new IO::Select($stdin,$net); $net->autoflush(0); while (1){ foreach my $i($sel->can_read(0.05)){ if($i==$net){ &dosomething; $net->flush; } else{ &dosomething2; $net->flush; } } }