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.
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.
Socket.IO requires a lot of memory which is a potential problem.
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.
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.
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.
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.
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.
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.
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.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With