title: Client not receiving all messages using websockets
body: <p>I have a WebSockets server set up on localhost, using <a href="http://code.google.com/p/phpwebsocket/" rel="nofollow noreferrer">phpwebsocket</a>. The client is sending 2 messages to the server ('hi server') at almost the exact same time as so</p>
  
  <pre><code>socket.send('hi server');
  socket.send('hi server');
  </code></pre>
  
  <p>The server is receiving both messages and replying back with the message 'sup client'.</p>
  
  <pre><code>...
  case "hi server": $this-&gt;send($user-&gt;socket,"sup client"); break;
  ...
  function send($client,$msg){ 
      echo "&gt; ".$msg;
      $msg = $this-&gt;wrap($msg);
      socket_write($client,$msg,strlen($msg));
      echo "! ".strlen($msg)."\n";
  } 
  ...
  function wrap($msg=""){ return chr(0).$msg.chr(255); }
  </code></pre>
  
  <p>The php log looks like this:
  <img src="https://i.stack.imgur.com/a1Qnu.png" alt="phplog"></p>
  
  <p>The code for the client receiving messages:</p>
  
  <pre><code>socket.onmessage = function(msg)
  {
      log("Received: " + msg.data);
  }
  </code></pre>
  
  <p>What the client is actually logging inside the div element:
  <img src="https://i.stack.imgur.com/91fZF.png" alt="client"></p>
  
  <p>I have no idea why the client is only processing one message when the websocket server sent 2. I should have 2 'Received: sup client' in that div tag. I'm thinking maybe its sending the messages a bit too fast for the JavaScript or something.</p>