News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Saran Chamling:
Simple Chat Using WebSocket and PHP Socket
July 30, 2013 @ 10:38:41

While not a recent article, this post from Saran Chamling is definitely interesting. In it he shows you how to create a real-time chat by combining PHP and WebSockets.

The WebSocket is a feature of HTML5 for establishing a socket connections between a web browser and a server, once the connection has been established with the server, all WebSocket data (frames) are sent directly over a socket rather than usual HTTP response and requests, giving us much faster and persistent communication between a web browser and a server. Let's create a simple chat system using this cool technology (HTML5 WebSocket and PHP).

He includes all the code you'll need to get things up and running, starting from the WebSocket side. With a simple socket connection and some jQuery to control it, the system connects to the backend PHP script. The PHP script reads directly from the socket (using the socket_* functions) and binds to it, waiting for incoming requests. There's also some sample code showing how to work with the "handshake" between the WebSocket and PHP and how to respond. If you want something a bit easier to work with and more functional, consider checking out Ratchet, a WebSocket server for PHP.

0 comments voice your opinion now!
websocket realtime tutorial chat socket

Link: http://www.saaraan.com/2013/05/chat-using-websocket-php-socket

blog comments powered by Disqus

Similar Posts

Bhaskar Karambelkar\'s Blog: Prototyping LAMP with WAMP

Manuel Pichler's Blog: Howto create custom rule sets for PHPMD

Zend Developer Zone: Desktop Image Uploaders Using Adobe AIR and JavaScript

DZone.com: Building a Flickr Slideshow with NetBeans IDE 6.5

Michelangelo van Dam's Blog: Single User Zend_Service_Twitter


Community Events

Don't see your event here?
Let us know!


php7 conference api framework series part2 introduction performance interview configure example laravel opinion release symfony2 library voicesoftheelephpant application podcast community

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework