I have recently come upon Node's net module, I was wondering if using this module would be the equivalent of using the socket.io module. What is the difference between them ? thanks!
socket-io. client is the code for the client-side implementation of socket.io. That code may be used either by a browser client or by a server process that is initiating a socket.io connection to some other server (thus playing the client-side role in a socket.io connection).
Key Differences between WebSocket and 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. WebSocket is the technology, while Socket.io is a library for WebSockets.
Socket.IO is way more than just a layer above WebSockets, it has different semantics (marks messages with name), and does failovers to different protocols, as well has heartbeating mechanism. More to that attaches ID's to clients on server side, and more. So it is not just a wrapper, it is full-featured library.
Pusher is the category leader in delightful APIs for app developers building communication and collaboration features. On the other hand, Socket.IO is detailed as "Realtime application framework (Node. JS server)". Socket.IO enables real-time bidirectional event-based communication.
I have recently come upon Node's net module, I was wondering if using this module would be the equivalent of using the socket.io module.
No, they are not even close to the same thing.
Node's net module is a basic low level TCP and UDP interface. It allows you to make a TCP or UDP connection to some endpoint and to then send or receive data from that endpoint over that connection. These are raw TCP connections. You define the protocol, data format and all conventions used in the communication. All TCP does is deliver your data from one end to the other.
socket.io is somewhat at the other end of the network stack.
socket.io
webSocket
TCP
A webSocket is built on top of TCP. It has it's own unique connection scheme that starts with an http connection with certain custom headers and then requests an "upgrade" to the webSocket protocol. If the server approves the upgrade, then the same TCP socket that the http connection started over is converted to the webSocket protocol. The webSocket protocol has it's own unique encryption and data format.
Socket.io is built on top of the webSocket protocol (meaning it uses the webSocket protocol for it's communication). Socket.io has it's own unique connection scheme (starts with http polling, then switches to a regular webSocket if permissible) and it has an additional data structure built on top of the webSocket data frame that defines a message name and a data packet and a few other housekeeping things.
socket.io and webSocket are both supported from browser Javascript. A plain TCP or UDP connection is not supported from browser Javascript. So, if you were looking to communicate with a browser, you would not be using plain TCP.
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