What is difference between WebSockets and Socket.io?

ADJ

Scenario: I'm new to JavaScript (have experience C/C++/Java), and working on a React UI with NodeJS server wherein the server will get updates on the displayed data at specific intervals (say 5 secs). The server is supposed to push the data to React UI to update the displayed data quickly.

Contenders: I came across 2 JS libraries Websockets (is lib a right term for websocket?) and Socket.io to achieve this. To me they both appear same.

Did I Google?: Yes, but with my lack of knowledge of JS, I couldn't understand the difference.

Problem: What is the difference between these 2 libs (libs?) and how can I decide which one is more suitable here?

dropbeardan

Scenario: I'm new to JavaScript (have experience C/C++/Java), and working on a React UI with NodeJS server wherein the server will get updates on the displayed data at specific intervals (say 5 secs). The server is supposed to push the data to React UI to update the displayed data asap.

This is how I would do it.

Contenders: I came across 2 JS libraries Websockets (is lib a right term for websocket?) and Socket.io to achieve this. To me they both appear same.

In short, I am aware of two different ways of communicating between the server and client: WEBSOCKET and SERVER-SENT EVENTS (SSE). They are slightly different so it would be highly advisable to Google both options to find out which would suit you better.

Socket.io is essentially a library to assist with the creation/management of websockets. Imagine it to be your .NET Framework when you could have written a system yourself in C instead.

Did I Google?: Yes, but with my lack of knowledge of JS, I couldn't understand the difference.

Here are some links that can help you:

SSE:

  1. https://www.w3schools.com/html/html5_serversentevents.asp

  2. https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events

WEBSOCKET

  1. https://www.html5rocks.com/en/tutorials/websockets/basics/

  2. https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_client_applications

COMPARISON

  1. https://www.google.com.au/search?safe=off&ei=MmNLWuGkLsHQ0AS87J_4Bw&q=websocket+vs+sse&oq=websocket+vs+sse

Problem: So can you please help me understand the difference between these 2 libs (libs?) and help me decide which one is more suitable here?

As I have mentioned before, you have technically only mentioned one package library (socket.io) which manages the websockets via their API. I would assume the other method would be to do it manually using the native JavaScript method. It is up to you which one you choose and you'll surely find that there are advantages and disadvantages with both.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

What is the difference between @nestjs/websockets and @nestjs/platform-socket.io packages in NestJS

What is the difference between Socket.IO and Firebase?

Difference between the socket , socketio, and websockets

What is the difference between ServerSockets and Websockets?

Differences between socket.io and websockets

What's the difference between socketIOClient and webSocket in socket.io in nodejs?

What is the difference between io.sockets.emit and socket.emit in io.on('connection', function(socket){})?

What is the fundamental difference between WebSockets and pure TCP?

Flask socket IO - what is difference between send and return in socket.on method

What is the difference between lscpu Socket and networking Socket?

socket.io rooms difference between to and in

socket.io-Difference between emit functions

What's the difference between '_io' and 'io'?

Difference between MessageChannel and WebSockets?

what's the difference between type and protocol in socket()?

What is the relationship between ws engine.io and socket.io

What's the difference between Task and IO in Scalaz?

What is the difference between socket.send() and socket.sendall()?

Difference between socket.io and Node's Net module

What's the difference between io.Copy and io.CopyBuffer?

What is the difference between io:format and io:fwrite in Erlang?

How to use WebSockets and Socket.IO with flutter?

Moving from socket.io to raw websockets?

React-Redux and Websockets with socket.io

Websockets transport only in Socket.io 1.3.4

connect 2 websockets ws and socket.io

What are IO ports, serial ports and what's the difference between them?

What is the difference between using a router and connecting a PC straight into the wall socket?

What is the difference between closing Input/OutputStream and closing Socket directly?

TOP Ranking

HotTag

Archive