use strict; use IO::Socket; use IO::Socket::INET; my $CRLF = chr(13).chr(10); use constant SERVER_PORT => 40411; use constant KEEPALIVESEC => 10; my $sock = IO::Socket::INET->new(PeerHost => 'localhost', PeerPort => SERVER_PORT, Proto => 'tcp'); if($sock->connected) {  print "KARAMBA\n";  local $SIG{ALRM} = sub {     if($sock->connected)     {        $sock->write("E$CRLF", 3); $sock->getline();        alarm KEEPALIVESEC;     }  }  alarm KEEPALIVESEC;  my $request = "";  my $response = "";  while(lc($request) ne "quit" and lc($response) ne "quit")  {           print "Eingabe: \n";     $request = ;         alarm KEEPALIVESEC; # alarm reset (hoffentlich; kenn ich damit gar nicht aus)     chomp $request;     $sock->write("$request$CRLF", length($request)+2);     print "YOU wrote: [$request]\n";     $response = $sock->getline();     chomp $response;     $response =~ s!$CRLF$!!g; # to be sure     print "SERVER wrote: [$response]\n";  }  alarm 0;               # race condition protection }