I\'m trying to make a nodejs(socket.io) server to communicate with another one. So the client emits an event to the \'hub\' server and this server emits an event to some sec
The native Node TCP module is probably what you want - I wanted to do what you're trying to do but it seems that the fact that WebSockets are strictly many-browser to server, or browser to many-server.
You can weave a tcp strategy into your websocket logic.
Using tcp:
var net = require('net');
var tcp = net.connect({port: 3000, host: 'localhost'});
tcp.on('connect', function(){
var buffer = new Buffer(16).fill(0);
buffer.write('some stuff');
tcp.write(buffer);
});
tcp.on('data', function(data){console.log('data is:', data)});
tcp.on('end', cb);
tcp.on('error', cb);
I would use a bridge pattern with this:
https://www.google.com/search?q=javascript+bridge+pattern&aq=f&oq=javascript+bridge+pattern&aqs=chrome.0.57.6617&sourceid=chrome&ie=UTF-8
OR, use the Node Module https://npmjs.org/package/ws-tcp-bridge
I also heard that using redis can be quite helpful - Socket.io uses this as a fallback.
Hope this helps...
Cheers