Back to blog

Socket.IO: sockets for the rest of us

Guillermo Rauch // March 17th 2010 // 
GitHub Docs Download

LearnBoost aims to provide a really realtime experience in the collaboration between peers and teachers.

This task is not easy to accomplish in the web nowadays. There exists a wide variety of technologies and techniques that have very different underlying mechanisms. Terms like WebSocket, long-polling, iframe streaming, server-sent events, multipart requests, probably come to mind.

The problem, however, is the way the HTTP protocol is implemented for each of those techniques. While they do provide you with the tools to create a realtime application, the mechanisms to make them work are so inherently different that it becomes hard to separate your own application logic from the data transport layer logic.

Socket.IO aims to solve this problem for you.

It consists of two parts: a simple, object-oriented, framework-agnostic client, and a Node.JS server. Both, of course, written in JavaScript.

This is the API exposed in the client side:

Very simple, right? What truly makes it amazing is that, despite it’s similarity to the WebSocket API, it might be really using a hidden iframe in an ActiveXObject instance for Internet Explorer, or maybe Flash for those who still use it, or long-polling for your iPhone application.

And the same simplicity is kept on the server side. This is what it took me to write a chat application (albeit very simple):

Head to GitHub here and here for more information. If you find any Issues please report them, or fork and hack away!

Also don’t hesitate to share your thoughts or ideas on how to improve it.

Guillermo Rauch
LearnBoost Software architect

Want the best gradebook and lesson plan software on the web? Get your free account!