Back to blog

October 06, 2023

avataravatar

Gautam Patoliya, Deep Poradiya

Tutor Head

Introduction to Socket.IO

blog-img-Introduction to Socket.IO

Socket.IO was created by Guillermo Reach in 2010. It was developed to use open connections to facilitate real-time communication, which was still a relatively new phenomenon. That is written in JavaScript. That official website is socket.io and the repository of GitHub is https://github.com/socketio/socket.io.


Let you understand Socket.IO in very simple language. We people must have used chat applications. Let's take an example WhatsApp. If you message someone in it, it gives you a real-time experience. In which someone messages from the front. So it shows you this message at the same time (typing...). And if it sends a message, you don't have to refresh the page and it will show you the message directly.


 Let's understand this topic technically. When the first user is typing something then the second user should know that the first user is typing (similar to gtalk of Facebook messenger). If you use HTTP calls then the second person will never be able to see the actual status of the other person because of the delay. When we use sockets so that when the first user is typing anything his device will send only one data packet which will just notify the server that he is typing and will be delivered to the second user, this process is fast and almost real-time and will reduce the data transfer also.


This is an event-driven library. They are two parts: first, a client-side library that runs in the browser, and second a server-side library for Node.js.



Socket.IO allows bi-directional communication between client and server.



That establishes the connection, and exchanges data between the client and server, Socket.IO uses Engine.IO. This is a lower-level implementation that is used under the hood. Engine.IO-client is used for the client implementation and Engine.IO is used for the server implementation.Socket.IO also has a large community, Due to this, it is quite easy for us to find help.


Most real-time systems are architected with the help of sockets. It provides a bi-directional communication channel between the server and the client. The server can send a message to the client and the client can also send messages to the server. 


Socket.IO is very popular. That is used many organizations use to build robust real-time systems like Zendesk, Microsoft Office, Trello, and many more organizations. It is one of the most powerful JavaScript frameworks on GitHub, and the most depended-upon NPM (Node Package Manager) module. 

 


Using Socket.io which type of applications can be created?    


1) Instant Messengers:


These are the applications that you don't need to refresh if a new message comes. In that way, the message comes without refreshing. Such applications are called instant messenger apps. Many of them are taken by us in regular use. Like WhatsApp, Discord, WhatsApp Business, Facebook Messenger, WeChat, Snapchat, ShareChat, Google Chat, and Slack, ... there are many applications.



2) Instant Notifications:


This is the type of app where you will get instant notification if someone tags you. ex., Discord, Instagram, Facebook, etc...



3) Collaboration Applications:


Collaboration Applications are allowed to add and update to the same document at the same time by different users. And applications are allowed them. Due to this, many tasks become easy. It also saves time. Google Meet, Google Docs, Asana, ClickUp, Slack, Trello, Skype, and many more applications are included in Collaboration Applications.



4) Multiplayer Gaming:


Online gaming applications are those applications that help to establish bi-directional communication between multiple users. Examples of real-time online games are Chess, Call of Duty, Among Us, League of Legends, GTA Online, etc.



 In this way, we can create real-time, user-friendly, and beautiful applications using Socket.IO.



ReactJs