Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between socket.io and node.js

What's the difference (purpose) between socket.io and node.js projects?

like image 359
Cartesius00 Avatar asked May 24 '12 22:05

Cartesius00


2 Answers

They have nothing to do with each other, fundamentally.

Node.js is host for JavaScript, and is commonly used as an event-driven server.

Socket.IO is a wrapper for Web Sockets that allows simple communication between clients and servers. It also serves as a method to introduce Web-Socket-like functionality in browsers that do not natively support Web Sockets.

Your confusion likely stems from the fact that Socket.IO is hosted within Node.js projects on the server. For comparison, your question is similar to "What is the difference between cars and roads?" They are used with each other, but are not the same thing. There is probably a better analogy here, but I cannot think of one. Perhaps someone else could comment and add to this.

like image 134
Brad Avatar answered Sep 19 '22 20:09

Brad


Simply, node.js is a run-time environment to execute JavaScript on the server.

socket.io is a framework built on top of node.js to enable web socket communication between a client and server.

like image 32
stan Avatar answered Sep 18 '22 20:09

stan