title: How do we write some data when socket operation is going on
body: <p>I am new to sockets , and I am trying to display some data for the user to tell him to wait , while socket is fetching the data from the server , I used ob_flush , flush and some other functions also , but they didnt work, the text "Loading .... Please Wait" only appears after the socket is closed  , Here is my code </p>
  
  <pre><code>$fp = fsockopen("tcp:.......", port num, $errno, $errstr);
  if (!$fp) 
  {
      echo "ERROR: $errno - $errstr&lt;br /&gt;\n";
  } 
  else 
  {
      echo "Loading .... Please Wait";
      flush();
      fwrite($fp, $num . "\n");
      ini_set('max_execution_time', 600);
      $cmd_res = fread($fp, 1000);
      echo $cmd_res;
      fclose($fp);
  }
  </code></pre>
  
  <p>If you have any solution , Please help me . Thanks in advance</p>