Can I use the socket io library on the client side and a completely different websocket library on the server side? - websocket

I am starting with websockets.
I've come across a bit of a puzzle in my head and I hope someone will be able to answer this question for me
Can I use the socket.io library on the client side and a completely different websocket library on the server side?

Related

Why does the PeerJS PeerServer use WebSockets?

The code of the PeerServer for PeerJS mostly consists of WebSockets. I don't see any references to WebRTC.
Why are they using WebRTC for connections to the PeerServer? Is this not possible using WebRTC?
In that case, are there really any differences between using Socket.IO or PeerJS for sending messages between clients?
WebRTC only contemplates the connection part between to peers that know each other, as the discovering part is left to be solved by another tool, peerjs is a good tool to that matter...

Does socket.io needs its counterpart on a server?

I would like to use socket.io or engine.io on client, but does it implies having a corresponding implementation on the server ? so socket.io on Client and a Java server with socket.io for instance ? Thx
Yes, a socket.io client must be talking to a socket.io server on the other end. socket.io is its own protocol on top of webSockets so you must have a reciprocal server on the other end that speaks the same protocol.
There are implementations of socket.io server for many server-side languages, including Java, Javascript, C++, C#, etc...

What is the relationship between ws engine.io and socket.io

This question basically makes it sound like the node library Socket.io uses the library engine.io which uses ws.
What role do each of these play given that each one can independantly create a WebSocket connection?
Look at Introducing Socket.IO 1.0 - New engine to see why they made Engine.IO.
Engine.IO has all the browser hacks and different things for compatibility, and has modularised the Socket.IO codebase.
You are correct that Socket.IO uses Enginge.IO which uses ws.
Engine.IO takes care of the connection and browser hacks.
ws is used when upgrading to websockets.
Socket.IO handles:
setup/connection to http.Server. (but engine.io has this as well)
list of clients
rooms
namespaces
decoding/encoding of Socket.IO packet format

Dart websocket in dart:io and dart:html

I have seen two implementation of websocket in dart:io and dart:html. Which one should I use? Currently I prefer more the websocket in dart:io since it seems to fit more naturally how dart handle streams and asynchronous programming.
The dart:html library is used on the client-side and can be compiled to JavaScript.
Use dart:io for server-side code.
In a typical setup, you have a web server listening to WebSocket connections from the client, in which case you would use the one from dart:html. But of course you can also initiate WebSocket connections at the server if you ever need :)
dart:io is only available on the server
dart:html is only available in the browser

Starting with WebSockets

I had a huge confusion in WebSockets. I read some blog about WebSockets and it requires node websocket server, I downloaded the demo files and the chat application didn't seem to work. To summarize this, what do I need to use WebSockets? Do I need to download node server or something? And what is something to relate with socket.io to one another?
WebSockets?
WebSockets is a standard for implementing socket communication (to a server) over the web.
Is node required?
Now this server which the socket communication prevails between can be implemented in any way whatsoever. Node is surely a popular option to implement the server side in however its not the only, you can use python, erlang, ruby, or any other language where you can bind a socket connection.
What is socket.io?
socket.io is javascript library which makes it possible for socket OR socket-like connections over the web. See the WebSockets is a recent standard, not all browsers support it, only the modern ones do (proof: http://caniuse.com/#search=websockets). What makes socket.io so popular, rainbow and fairy tale like (and one of the main reasons why you happened to stumble upon it while researching WebSockets) is that it will make socket/socket-like communications possible in all browsers.
socket: when socket.io detects a browser supporting WebSockets, in which case it uses this WebSockets implementation for the socket communications.
socket-like: however when socket.io detects a browser which does NOT support WebSockets it will still provide you with socket-like communication. Tid bit: the internals of this feature use AJAX polling.
Node is a good place to start for websockets, but by no means the only place.
I would probably start here:
http://www.html5rocks.com/en/tutorials/websockets/basics/

Resources