Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the relation between WS and socket.io?

I just installed socket.io for the first time, and at the end it gave me this message:

To install WS with blazing fast native extensions, use
<npm install ws --ws:native>

What does that mean? Is WS replacement for socket.io? I googled around and I can't figure it out. Or is it replacement for node.js? Or is it something I can install alongside socket.io and node.js?

Also I assume the message refers to this ws?

like image 220
Milan Babuškov Avatar asked Nov 17 '25 20:11

Milan Babuškov


2 Answers

Websockets (or ws) is one possible transport for socket.io (others are flashsocket, htmlfile, xhr-polling and jsonp-polling)

socket.io is basically a wrapper to help you transparently use best transport available in your browser

like image 164
Andrey Sidorov Avatar answered Nov 19 '25 09:11

Andrey Sidorov


Apparently, ws is a dependency of socket.io-client, which is a dependency of socket.io. If you want to build native extensions for ws, you can pass --ws:native to npm.

You see the message because ws echo it when not being installed with --ws:native. You can safely ignore the message, or try passing --ws:native to npm when installing socket.io.

AFAICT, socket.io-client only uses it to connect to a socket.io server from node.js -- i.e. only for testing purposes. So it really shouldn't matter whether you compile it with native extensions or not.

like image 32
Linus Thiel Avatar answered Nov 19 '25 09:11

Linus Thiel