title: Perl server client issue (buffer not flush)
body: <p>I do have below client and server written in perl. Issue is client never properly send and receive message from server. 
  requirement is to send a message to server and get the response from server and based on that take the decision. I have write a server client test classes with STDOUT and STDIN and those working fine. I think that because I press ENTER after every send command.</p>
  
  <p>Client</p>
  
  <pre><code>#!/usr/bin/perl
  
  my $rhostname='192.168.0.181';
  my $hostname="support";
  my $port='7071';
  my $script_log_dir="/var/sdplog/support";
  
  use IO::Socket; 
  use strict;
  
  $| = 1;  
  my $host_ip='0.0.0.0';
  my $host_port='7088';
  my $sock = new IO::Socket::INET ( 
      PeerAddr =&gt; $rhostname, 
      PeerPort =&gt; $port,
      Proto =&gt; 'tcp', 
     ); 
     die "Could not create socket: $!\n" unless $sock; 
     $sock-&gt;autoflush(1);
  
     my $query = "START:192.168.0.20:3:1:1:".$host_ip.":".$host_port;
  
     my $count=0;
  
     print "sending $query\n";
     print $sock "$query";
  
     my $data = &lt;$sock&gt;;
     print $data;
     close($sock);
  </code></pre>
  
  <p>Server -  code</p>
  
  <pre><code>while ($q != -999){
      $logger-&gt;debug('waiting for socket....');
      my $new_sock = $sock-&gt;accept();
  #       sleep(5);
      $i++;   
      $logger-&gt;debug($i.' accept');
      while(&lt;$new_sock&gt;) {
  
      #       print $_;
              $logger-&gt;debug("received command - ".$_);
              my $ip_status = 2;
  
              @input_command = split(':', $_);
  
              $command = @input_command[0];
              $server_ip = @input_command[1];
              $retry_count= @input_command[2];
              $wait_time = @input_command[3];
              $next_ping_wait = @input_command[4];
              $client_ip = @input_command[5];
              $client_port = @input_command[6];
  
              @ping_array=($server_ip,$retry_count,$wait_time,$next_ping_wait);
              $logger-&gt;debug("received request ".@input_command);
              $logger-&gt;debug($command);
              if ($command eq "START"){
                      $logger-&gt;debug($command." received. checking server status");
                      $ip_status = network-&gt;ping_ip(@ping_array);
                      $logger-&gt;debug("ping status - ".$ip_status);
  #                       $logger-&gt;debug($client_ip.$client_port);
      #               send_message($client_ip,$client_port,$ip_status); # do some 
                      sleep(2);
                      print $new_sock "$ip_status\n";
  
              }else{
  
                      $logger-&gt;debug($command." received");          }
              }
  }
  
  close($sock);
  exit 0;
  </code></pre>
  
  <p>Server is in listening state. When I run the client below is the output.</p>
  
  <pre><code>&gt;perl client.pl 
  sending START:192.168.0.20:3:1:1:0.0.0.0:7088
  </code></pre>
  
  <p>On server</p>
  
  <pre><code>2012/08/21 18:49:04 DEBUG&gt; server.pl:89 main:: - waiting for socket....
  2012/08/21 18:49:08 DEBUG&gt; server.pl:93 main:: - 1 accept
  </code></pre>
  
  <p>But thats all. Once I clicked CTRL+C client terminate and rest of the logs on server print as expected. Seems not flushing to read from server. </p>
  
  <pre><code>2012/08/21 18:56:05 DEBUG&gt; server.pl:97 main:: - received command -   START:192.168.0.20:3:1:1:0.0.0.0:7088
  2012/08/21 18:56:05 DEBUG&gt; server.pl:113 main:: - received request 7
  2012/08/21 18:56:05 DEBUG&gt; server.pl:114 main:: - START
  2012/08/21 18:56:05 DEBUG&gt; server.pl:116 main:: - START received. checking server  status
  2012/08/21 18:56:05 DEBUG&gt; network.pm:31 network::ping_ip - 192.168.0.20 is alive
  2012/08/21 18:56:05 DEBUG&gt; server.pl:118 main:: - ping status - 1
  2012/08/21 18:56:07 DEBUG&gt; server.pl:89 main:: - waiting for socket....
  </code></pre>
  
  <p>But wasn't able to find a solution. Please shed some light as I am stuck in this for few hours now.</p>