title: Sockets: Why does my message from the server always get split up into the exact same 2 messages?
body: <p><strong>This php snippet is on the server-side:</strong></p>
  
  <pre><code>if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) === false) 
      echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "\n";
  
  
  //bind the socket to the ip address and port
  if (socket_bind($sock, $address, $port) === false) 
      echo "socket_bind() failed: reason: " . socket_strerror(socket_last_error($sock)) . "\n";  
  
  //make the socket listen for connections, SOMAXCONN is the max limit of queued sockets waiting to 
  //connect
  if (socket_listen($sock, SOMAXCONN) === false) 
      echo "socket_listen() failed: reason: " . socket_strerror(socket_last_error($sock)) . "\n";
  
  if (($client= socket_accept($sock)) === false) 
      echo "socket_accept() failed: reason: " . socket_strerror(socket_last_error($sock)) . "\n";
  
  if ( false === ($id = socket_read($client, 10, PHP_NORMAL_READ)) )
      socket_close( $client ); //close the socket connection
  
  $talkback = "PHP: Your id is '$id'.\n";
  socket_write($client, $talkback, strlen($talkback));
  </code></pre>
  
  <p><strong>This java snippet is on the client-side:</strong></p>
  
  <pre><code>while ((inputLine = in.readLine()) != null) 
      Log.i( "MY_TAG", "Message received: " + inputLine);
  </code></pre>
  
  <p>Where <code>inputLine</code> is a String, and <code>in</code> is the inputstream of my client-side socket.                                     </p>
  
  <p><strong>The output is ALWAYS:</strong></p>
  
  <p><code>Message received: Your id is '1</code></p>
  
  <p><code>Message received: '.</code></p>