What is Socket.io in 2 mins?

What is Socket.io in 2 mins?

What is Socket.io?

It is a javascript library that allows for webdevelopers to build asynchronized web applications (Real Time apps), which get and send data from and to the servicer when publish and without even calling it, For example, Real Time Chate web apps, or notifications apps like Twitter.

What is HTTP Protocole?

And before we continue, you should be aware that web apps are built in HTTP Protocole which depends on the user to send a request to the server and the server respond with the requested data from the user. to show in the browser, and finish the connection of the HTTP request.

Ok, so that means that the user has to send a request to the server to get his data, and this approach is not suitable for applications that need real-time action like message notifications which do not need any action or request from the user.

To solve this issue the great developers created a new connection protocol called WebSocket.


What is WebSocket?

It’s a protocol that provides an open connection channel between the user and the server which allow passing the messages through both directions from the user and to the server, without the need to create new request every time!!

Now, Let me tell you what is Socket.io?

Socekt.io is built on WebSocket Protocole, and it provides you some features that will make the development process more easier, work within Node.JS, and has huge popularity.

You should know that Socket.io does not fully depend on WebSocket Protocole, It also uses some other normal protocols when WebSocket is not supported.
ex, If the browser does not support WebSocket, so Socekt.io use other protocols, Long Polling for example, which helps to support more browsers and users.

Note: WebSocket Protocole is supported in most new browsers today.

Build App with Socekt.io

Apps that use socet.io consist of two parts, One from the user side and the other from the server side.
On the server side, we use Node.Js and from the user side, it is usually a web browser or web app with HTML and Javascript or other languages.

How Does Socekt.io Works?

Socekt.io is a library that depends on events, events send from one side and set listeners from the other side, in the service side we import the Socket.io library and use it to listen to events, and when the event triggers, a callback will be executed.

require(“socket.io”).on(“event name”,callback);

There are many socket.io functions to use like (on)-(emit)-(broadcast)-(room), Remember it is a Quick Ifeps.net Tip and not a Full tutorial, 
if you looking for video tutorials subscribe to my youtube channel and check the latest tutorials: Build a Zoom Clone | Flutter Tutorial


#buttons=(Accept !) #days=(14)

Our website uses cookies to enhance your experience. Learn More
Accept !