An Enthusiastic Developer

'Blogs on Web programming :-)';

Posts Tagged “PHP”

Build a real-time application using HTML5 WebSockets

Dec. 30, 2011

In this very first post on my new blog, I show you how I’ve carried out a simple push system using WebSocket specified by the RFC 6455 document. Unfortunately, I can’t bring you a live demo because of some hosting service restrictions that don’t allow me to create sockets. So, I worked on localhost with my own computer using Ubuntu, Apache and PHP-CLI. Nevertheless, you can download scripts on my github account.

You’ll find one of several basic implementations of a communication between clients and a server by WebSocket in PHP. I deliberately didn’t complicate the code (by adding other features or improvements) to make it easy to understand.

  1. How does a WebSocket basically work?
  2. The server side
    1. Handshake
    2. Unmasking/Encoding data frames
    3. Pushing data
  3. The client side
    1. Receiving data
    2. Leave the application
  4. More information