Using WebSockets
The WebSocket protocol, defined by IETF's RFC 6455, is a TCP-based protocol that enables two-way communication between a web page running on a browser and a server; even though it uses a single socket connection, both ends of the channel can send and receive information simultaneously, thanks to the full-duplex nature of the protocol. This connection is controlled by your application's code, unlike the HTTP protocol, where the browser itself manages the connections. This control is possible by the use of W3C's WebSocket API, which declares an interface to use the protocol.
With this feature we can directly communicate with a server in real time, bringing a whole new level of possibilities and sophistication to what can be accomplished on web applications.
Tip
To check which browser version has WebSocket support, access http://caniuse.com/websockets and look for the Current line on the table.
Let's see how to implement and test a really simple WebSocket that receives a message...