Is it possible to set up a socket.io client running (server-side) on a node.js server?

后端 未结 3 418
不知归路
不知归路 2020-12-08 02:55

I\'d like to enable socket-based p2p communications between two or more different node.js application servers. I\'m using socket.io to handle all such communication between

3条回答
  •  余生分开走
    2020-12-08 03:43

    Just for clarification, this is an example with listeners and possibility to emit events (and without install again a module already installed)

    var io = require('socket.io/node_modules/socket.io-client');
    
    client = io.connect('http://'+CONFIG.host+':'+CONFIG.port);
    
    client.on('connect',function() {
        client.emit("test","foo");
    }); 
    

提交回复
热议问题