run a tcp server to listen to a port range
michael sparacio
mjsparacio at me.com
Tue Mar 13 19:42:54 PDT 2012
I am not familiar with js but trying to get an example.js coded properly, this is only listening on the final port, the 10100...
var net = require('net');
var port = 10000
for (port = 10000; port < 10100; port++) {
;
}
var server = net.createServer(function(c) { //'connection' listener
console.log('server connected');
c.on('end', function() {
console.log('server disconnected');
});
c.write('hello\r\n');
c.pipe(c);
});
server.listen(port, function() { //'listening' listener
console.log('server bound');
});
I assume I am making a dumb error??
thanks for any suggestions.
-ms
On Mar 13, 2012, at 5:12 PM, Ryan Schmidt wrote:
>
> On Mar 13, 2012, at 16:10, michael sparacio wrote:
>
>> Is there a recommended port that will listen to a range of tcp ports? I am playing with netcat but it seems it can only listen to a single port at a time. I'd like to open hundreds or even thousands of tcp ports for firewall screens testing.
>
> nodejs is JavaScript environment with which it's very easy to create network servers that do whatever you want them to. Perhaps that will help you.
>
> http://nodejs.org/
>
> Yes, you can install nodejs with MacPorts.
>
> sudo port install nodejs
>
>
More information about the macports-users
mailing list