i want to developp a messenger web app in realtime with nodejs and i wanted to know what's the best choice between websocket and socket.io for the server and the client side.my concerning is performance, like if i use websocket in both server and client side or socket.io what would be more performant. THX THX.
2 Answers
socket.io was built on top of WebSocket. So there is no chance for it to be any faster than WebSocket. I think the role of socket.io to WebSocket is quite similar to the role of jQuery to Javascript. socket.io has fallback solutions when WebSocket is not available. So basically, it supports more browsers. I personally prefer to use WebSocket over socket.io. It's not because of performance advantage, it's actually about having more controls over the application architecture.
4 Comments
socket.io forces you to use the event model for delivering messages. I personally think it's not a good choice of architecture.Don't compare Websockets over socket.io, Websocket is a protocol while socket.io is a socket framework (javascript) that uses Websocket as one of it's protocol. Socket.io (client) will use Websocket in communicating whenever it's supported, as a fallback, it will use the old-fashioned polling method when Websocket is not supported by the clients device.
3 Comments
websocket is a protocol, and socket.io is a framework that uses websocket as one of it's protocol. socket.io makes the use of the websocket api to connect/send/receive data, socket.io make it easier to use the websocket api through it's own api.