Hey guys I have a problem with node and I hope you can help me.

So the problem is that i have 9 network devices that are all listening on 
the same port lets call it X these device all connect to the node JS server 
and sending strings to the server. Now my problem is that between the 9 
devices and the nodeserver is a router that shall map the connections with 
different ports. I dont know much router and networking but what i know is 
that the router maps 9 different ports to X our port that the devices are 
using. Now i need node to write over the tcp protocoll via this matched 
ports to communicate with the devices. How can i do it. When i have these 9 
clients connected to my server they all have different remotePorts and 
furthermore not the ones i would like them to have. 

Is there any possibility to change the ports or to define them? Because I 
am not allowed to make all ports accessable.

Heres my sample code for a little server that connects n clients:

function server(port){
this.port = port;
 this.clients = new Array();
this.web;
}

server.prototype.listen = function(){
this.connection = require('net').createServer();
this.connection.listen(this.port, (function(){
console.log('server listening on ' + this.port);
}).bind(this));
  return this.connection.on('connection', this.addClient.bind(this));
};

server.prototype.addClient = function(socket){
this.clients.push(new client(socket, this));
};

function client(socket, server){
this.socket = socket;
this.server = server;
 this.ip = socket.remoteAddress;
this.port = socket.remotePort;
 this.socket.on('connect', (function(){
console.log('client:\nremoteAddress: ' + this.ip + '\nremotePort: ' + 
this.port);
}).bind(this));
}

tcp = new server(2222);
tcp.listen();



Here is also a small sketch that i made:

<https://lh3.googleusercontent.com/-jdoqFo0RIz4/UOgN9HcCVAI/AAAAAAAAAAU/QbYT4ylYvMU/s1600/node+problem.png>
I hope this helps

And Thank you

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to