use IO::Socket::INET; my $port = 10405; my $host = 'server'; my $socket = IO::Socket::INET->new(PeerAddr => "$host", PeerPort => $port, Proto => "tcp", timeout => 3, Type => SOCK_STREAM) || die "Could not establish connection : $!\n"; #$SIG{ALRM} = sub { print $socket "exit\n" }; my $header = <$socket>; print $socket "status"; #alarm(1); while(<$socket>) { chomp; print "$_\n"; } print "out of loop\n";