简体   繁体   中英

Whats the difference between socket.io and socket.io-client?

Whats the difference between socket.io and socket.io-client ?

Some project I'm trying to use is using socket.io-client, but I'm used to using plain old socket.io, and it dons't really lay it out in the documentation.

The main difference I'm aware of is that with the socket.io-client library you can connect your server to another server serving socket.io events.

For example, if my server at http://localhost is emitting a data event, I can listen on another server like so:

var socket = require('socket.io')('http://localhost');
  socket.on('connect', function(){
    socket.on('data', function(data){
      // Do something with data
    });
  });

and respond accordingly with the data object passed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM