Simple HTTP is great for things that don't need real-time data, but what about when we need to know about things as they happen. For example, if we were creating a website that had a chat interface or similar?
This is when something like Web sockets come into play. Web sockets are usually referred to as WebSockets and are full duplex or two-way low-latency communication channels. They are generally used by messaging applications and games where messages need to be relayed between the server and client. There is a really handy
npm module called
socket.io, which can add Web sockets to any Node.js application.
To install it we just need to run:
[~/examples/example-27] npm install socket.io
Socket.IO can be set up very simply to ...