Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js and socket.io confusion

I so often see titles like "Node.JS + socket.io tutorials." Even in the Node.js Beginner book I've purchased, it tells me to download socket.io so I'm getting really confused.

What's the difference between them? Why can't I code my applications just with Node.JS "OR" Socket.io? If I can code, why do people socket.io plus node.js in titles?

I'm really confused so any kind of replies would be appreciated.

like image 231
Aris Avatar asked Dec 20 '12 03:12

Aris


People also ask

Does Socket.IO need node JS?

In this guide we'll create a basic chat application. It requires almost no basic prior knowledge of Node. JS or Socket.IO, so it's ideal for users of all knowledge levels.

Does Socket.IO use a lot of memory?

Socket.IO requires a lot of memory which is a potential problem.

Which is better Socket.IO or WS?

Both WebSocket vs Socket.io are popular choices in the market; let us discuss some of the major Difference Between WebSocket vs Socket.io: It provides the Connection over TCP, while Socket.io is a library to abstract the WebSocket connections. WebSocket doesn't have fallback options, while Socket.io supports fallback.

What is the use of Socket.IO in node JS?

Socket.IO is a library that enables low-latency, bidirectional and event-based communication between a client and a server. It is built on top of the WebSocket protocol and provides additional guarantees like fallback to HTTP long-polling or automatic reconnection.

What is socket Io in Java?

Socket.IO is a library that enables real-time, bidirectional and event-based communication between the browser and the server. We can connect client and server responding to each other using socket.io. BUT Socket.IO is NOT a WebSocket implementation.

How do I use NodeJS and WebSocket for 2 way communication?

We will use Node.js for the backend platform and Socket.io for real-time two-way communication. First, we need to create a package.json file to install our required dependencies. WebSocket is the internet protocol that allows for full-duplex communication between servers and clients.

What is socket Io and why should I Care?

This is because Socket.IO provides a layer of abstraction over native WebSockets. It comes with some excellent features, such as a fallback mechanism for older browsers that do not support WebSockets and the ability to create “rooms”. Here, I have created a server variable and passed the express application.

What is WebSockets?

WebSocket is the internet protocol that allows for full-duplex communication between servers and clients. This protocol goes beyond the typical HTTP request/response paradigm; with WebSockets, the server may send data to a client without initiating a request, thus allowing for some exciting applications.


3 Answers

Socket.io is a framework on node.js for realtime applications. So, both is required if you want to use socket.io. You can code your own to do the same thing but socket.io is cross-browser and by using it can help you save time.

like image 44
Licson Avatar answered Sep 19 '22 00:09

Licson


node.js is a platform.

socket.io is just a framework for dealing with websockets if your are building an app on top of node.js.

socket.io needs node.js but node.js does not need socket.io

EDIT: Ryan Dahl's (node.js's creator) intro video is really instructive and helps with this kind of confusion: http://www.youtube.com/watch?v=jo_B4LTHi3I

like image 123
Felipe Sabino Avatar answered Sep 19 '22 00:09

Felipe Sabino


socket.io is a library, addition to actual platform which is node.js. It is like a software to computer. You can't use software without computer.

Node.js - is platform, that takes care about language - JavaScript visualization using V8 (JavaScript Engine that interpret JS script to understandable form to the computer). And lots of other components of platform.

While socket.io is just using features of platform, implements some cool own features that are addition to node. It is just a library, addition that you use along with the core.

In real world its like hoover - is a node.js, and nozzle is socket.io. Of course it is rough example, and things are much more complicated. But as you can see, nozzle is pointless without core.

Node.js makes your JavaScript running using own features. While socket.io is something you use or not - by your choice.

like image 38
moka Avatar answered Sep 21 '22 00:09

moka