title: Socket_recv MSG_WAITALL does not read full length
body: <p>I'm receiveing a socket response, in which the first 4 bytes are a packed int indicating the legnth of the message to recieve. We are receiving through <code>MSG_WAITALL</code> and it only recieves certain number of bytes before closing the connection. PHP Manual says this is normal "if a signal is caught". How would I get the full message, which is <code>$i["val"]</code> long?</p>
  
  <pre><code>$sock = socket_create(AF_INET, SOCK_STREAM, 0);
  socket_connect($sock , $server , 4656);
  socket_recv($sock, $i, 4, MSG_WAITALL);
  $i=unpack('Nval', $i);
  socket_recv($sock, $buf, $i["val"], MSG_WAITALL);
  </code></pre>
  
  <p>Specifically it only reads 2916bytes. If <code>$i["val"]</code> is less than that, it reads correctly, otherwise a max of 2916 bytes.</p>
  
  <p>Even when I loop, it won't read correctly, unless I loop through at 1byte at a time, which I think is not the proper way of doing it. Here's a loop at 2045b/loop.</p>
  
  <pre><code>$len=$i[val];
  echo 'Total Len: ' . $len . PHP_EOL;
  if($len&gt;=2045){
      $loops=floor($len/2045);
      echo 'Total Loops: ' . $loops . PHP_EOL;
      $last_loop=$len-(2045*$loops);
      echo 'Last Loop: ' . $last_loop . PHP_EOL;
      for($x=1; $x&lt;=$loops; $x++){
          socket_recv($sock, $buf, 2045, MSG_WAITALL);
          $reply.=$buf;
      }
      socket_recv($sock, $buf, $last_loop, MSG_WAITALL);
      $reply.=$buf;
  }else{
      socket_recv($sock, $buf, $len, MSG_WAITALL);
      $reply.=$buf;
  }
  echo 'Total Received: ' . strlen($reply) . PHP_EOL;
  </code></pre>