An Introduction to Websockets
This days a great evolution comes into web development. Many new technologies get introduces and web applications become better. Before few year each time we need to refresh web pages to get data after that Ajax came into light and solve this issue. Ajax became very usefull and using widely this days. But ajax itself has some limitations and suitable for half-duplex communications (one way communication). Suppose we to show notifications alert to user in that case we need to send an ajax request for a particular time interval to check if any notifications are there. This make unnecessary hits on server, consume bandwidth as well as increase unnecessary load on server. To overcome this problem websockets get introduced.
Websocket is protocol providng a full duplex communication over a TCP connection. While HTTP ot HTTPS was a protocole that supports half duplex communication and ajax use HTTP. Websocket create a persistent connection between client and server. So, anyone of them can send and receive data anytime.
A secure version of the WebSocket protocol is implemented in :-
- Firefox 6 and above (Was disabled in 4 and 5 due to security),
- Safari 6 and above
- Google Chrome 14 and above
- Opera 12.10 (Was disabled in 11 due to security)
- IE 10.4
Server Side Implementation library for Websockets :-
- C++ : libwebsockets
- Node.JS: ws, socket.io
- Java: Jetty
- PHP: Ratchet, phpws
- Python: Tornado, pywebsocket
- Ruby: em-websocket