Quantcast
Channel: BinaryTides » Html5
Viewing all articles
Browse latest Browse all 10

Websockets with php – tutorial on basics

$
0
0
Websockets
Websockets is a new feature available in browsers as a part of the Html5 specs that allows javascript clients to open bi directional socket connections to a server. Currently all major desktop browsers support the api.
Websocket is not an independant socket protocol, but is based on the TCP protocol just like HTTP. Therefore websocket connections are basically tcp socket connections that following the websocket rules to communicate. The protocol is is documented at RFC 6455.
So a separate socket server is needed to handle the websocket communications. The same web/http server like apache would not do that. Websocket server are run like normal daemons on linux for example.
Websocket url
A websocket url looks like this
ws://host:port/some/path
The important parts are host and port. It should be noted that the uri part after port is not necessary to establish the connection. It should not be confused to point to the path of the php server script or anything. It can be used by the server to locate resources. The connection is just made to the host on the given port number.
Now lets try to code up something using websockets.
Code
We shall use the following websocket server, written in php
https://github.com/ghedipunk/PHP-Websockets
The server itself is a class that can...

Read full post here
Websockets with php – tutorial on basics


Viewing all articles
Browse latest Browse all 10

Trending Articles