title: PHP Web Sockets - Handshake Made but Not Sending and recieving
body: <p>I've recently downloaded <a href="http://net.tutsplus.com/tutorials/javascript-ajax/start-using-html5-websockets-today/" rel="nofollow">http://net.tutsplus.com/tutorials/javascript-ajax/start-using-html5-websockets-today/</a></p>
  
  <p>php classes to create a PHP web sockets server.</p>
  
  <p>I've ran the startDaemon through command line and when I visit the client.php page, The handshake is clearly logged:</p>
  
  <pre><code>C:\wamp\bin\php\php5.3.5&gt;php -f C:/wamp/www/socket/server/startDaemon.php
  2011-09-09 13:55:42 System: Socket Resource id #7 created.
  2011-09-09 13:55:42 System: Socket bound to localhost:8080.
  2011-09-09 13:55:42 System: Start listening on Socket.
  2011-09-09 13:56:40 WebSocket: Resource id #8 CONNECTED!
  2011-09-09 13:56:40 WebSocket: Requesting handshake...
  2011-09-09 13:56:40 WebSocket: Handshaking...
  2011-09-09 13:56:40 WebSocket: Done handshaking...
  2011-09-09 13:58:18 WebSocket: Resource id #8 disconnected!
  2011-09-09 13:58:23 WebSocket: Resource id #9 CONNECTED!
  2011-09-09 13:58:23 WebSocket: Requesting handshake...
  2011-09-09 13:58:23 WebSocket: Handshaking...
  2011-09-09 13:58:23 WebSocket: Done handshaking...
  2011-09-09 13:59:14 WebSocket: Resource id #9 disconnected!
  2011-09-09 13:59:14 WebSocket: Resource id #10 CONNECTED!
  2011-09-09 13:59:14 WebSocket: Requesting handshake...
  2011-09-09 13:59:14 WebSocket: Handshaking...
  2011-09-09 13:59:14 WebSocket: Done handshaking...
  2011-09-09 14:00:16 WebSocket: Resource id #11 CONNECTED!
  2011-09-09 14:00:16 WebSocket: Requesting handshake...
  2011-09-09 14:00:16 WebSocket: Handshaking...
  2011-09-09 14:00:16 WebSocket: Done handshaking...
  2011-09-09 14:00:16 WebSocket: Resource id #11 disconnected!
  2011-09-09 14:00:23 WebSocket: Resource id #12 CONNECTED!
  2011-09-09 14:00:23 WebSocket: Requesting handshake...
  2011-09-09 14:00:23 WebSocket: Handshaking...
  2011-09-09 14:00:23 WebSocket: Done handshaking...
  2011-09-09 14:00:23 WebSocket: Resource id #12 disconnected!
  2011-09-09 14:00:33 WebSocket: Resource id #13 CONNECTED!
  2011-09-09 14:00:33 WebSocket: Requesting handshake...
  2011-09-09 14:00:33 WebSocket: Handshaking...
  2011-09-09 14:00:33 WebSocket: Done handshaking...
  2011-09-09 14:00:33 WebSocket: Resource id #13 disconnected!
  </code></pre>
  
  <p>(me making a few connections to test)</p>
  
  <p>my problem is I dont seem to be able to send or recieve info.
  in the php classes I have set stages to write 1,2,3... to the log at each point, which again you can clearly see through the command window. But when I try to send data, nothing is outputted to the log.</p>
  
  <p>Si I then went to the front end and tried this</p>
  
  <pre><code>if(!("WebSocket" in window)){
          $('#chatLog, input, button, #examples').fadeOut("fast");    
          $('&lt;p&gt;Oh no, you need a browser that supports WebSockets. How about &lt;a href="http://www.google.com/chrome"&gt;Google Chrome&lt;/a&gt;?&lt;/p&gt;').appendTo('#container');     
      }else{
          //The user has WebSockets
  
      connect();
  
      function connect(){
              //var socket;
              var host = "ws://localhost:8080/socket/server/startDaemon.php";
  
              try{
                  var socket = new WebSocket(host);
                  socket.onopen = function(){
                      alert('open');
                      message('&lt;p class="event"&gt;Socket Status: '+socket.readyState+' (open) &lt;/p&gt;');   
                  }
              ..........
              ........
  </code></pre>
  
  <p>WHere no alert is being made.... does anyone know what could be wrong here?</p>
  
  <p>regards</p>