What is Socket.IO ?

Written by - Saumya

08 December 2015

Once one starts working on NodeJS, very soon will come across a term called Socket.IO. It may feel as if just another NodeJS module available through NPM. Then it may feel like just another way to write a Javascript application for the browser. Then it may seem something else.

So lets know what is it?

  • Its two things, a server framework and client framework.
  • Its a NodeJS module ( install it from a NPM )
  • Its a client library ( .js file )

Now, lets understand a little more in detail.

Socket.IO is built to take advantage of WebSockets for a two way communication between server and client.

Server Framework

When you work on NodeJS to implement a socket server, Socket.IO makes your life easier by providing a NodeJS module. That means, without Socket.IO server module also, you can write a socket server with only NodeJS. That also means, you have to write and test your own socket server using NodeJS. This is possible with NodeJS provided built in modules but only take time and effort. In that sense we can say Socket.IO is a server framework for NodeJS to write socket servers.

Client Framework

Now to write a client (basically a web application) we can incorporate WebSockets API. Well, its possible in the same manner that we can write a Socket server by our own using NodeJS as explained above. But then Socket.IO provides us a ‘.js’ file with exposed APIs to use, which is cross-platform. That means Socket.IO gives a frontend framework too, to write our frontend Javascript applications.

Happy Noding.