#!/usr/bin/perl -l use warnings; use strict; #use diagnostics; use IO::Socket; use IO::Select; use IO::Handle; my $stdin = IO::Handle->new(); $stdin->fdopen(fileno(STDIN),"r"); my $remote_host = "192.168.2.2"; my $remote_port = 5000; my $clientsock = IO::Socket::INET->new(PeerAddr => $remote_host, PeerPort => $remote_port, Proto => "tcp", Type => SOCK_STREAM) or die "Konnte kein Kontakt zu $remote_host:$remote_port herstellen : $@\n"; my $sel = IO::Select->new(); $sel->add($stdin); $sel->add($clientsock); my $socket; while (1) { my @readyhandles = $sel->can_read(); foreach $socket (@readyhandles) { if ($socket == $stdin) { print $clientsock <$socket>; } else { print <$socket>; } } }