Sockets in general are just TCP streams that you can send data to. HTTP is built on top of them. WebSockets are built on / in parallel with HTTP and allow you to send data back and forth to the browser in real time. Standard sockets can perform some of these functions, but browsers have tight protection, which makes it difficult to use standard sockets to communicate with them.
WebSockets are useful when you need to constantly connect to the server from a browser, real-time applications, or things like push notifications.
Unfortunately, I know little about the PHP implementation, but it looks like there is a library here: http://code.google.com/p/phpwebsocket/
Personally, I shy away from doing such things in PHP because PHP / Apache can be quite heavy, and since the socket is always open and someone is viewing the page, server resources can be used quite quickly.
Many people like to use NodeJS with socket.io, because then you can use JavaScript on the server and in the browser, but actually it depends on preferences. I would look at Socket.IO and find a language that has a good client.
Seems like this question might be helpful too. Using PHP with Socket.io
loganfsmyth
source share