Installing Socket.io to Develop Realtime Applications

Socket.IO makes writing realtime, web and mobile apps possible, without having to worry about the details of the transport mechanism. Socket.io automatically selects the most capable transport at runtime, be it WebSockets, an Adobe Flash Socket, AJAX long polling, AJAX multipart streaming, Forever Iframe, or JSONP polling. What this means to you, is that you can easily and almost instantly emit messages between client and server, listen for them, and respond. This even works cross-domain.

Socket.IO is a node package, and a corresponding javascript file for the client-side. Using the same programming language (Javascript) on the client and server-side is a nice benefit.

Installing Socket.IO on your server is the first step. This tutorial assumes that you have already installed Node.js, which includes npm. If you haven’t done that, you should read our tutorial on installing Node.js on Ubuntu 12.04 LTS.

Install the the server-side component using npm, like this:

root@nodepod:~# npm install socket.io

For matching server-side and client-side examples that show how to use Socket.IO, we recommend checking out the Socket.IO web site. They also host the client-side javascript file so you will be able to try the examples very quickly.

Matthew McCaffrey

Leave a Reply