KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I would like to know if there's a way to scan through my local network's IP range for open ports of a specific number. Essentially I'm looking for nodejs to find clients of a specific type without knowing their IP addresses. In this case, RFID readers which listen on port 14150. I'd like this scan to be quick, so I don't want a long timeout between each IP address. They should all happen rather quickly, perhaps within a few seconds max for an entire local IP range of up to 255 clients, excluding my own IP. I wrote code that does what I want but it's painfully slow... I would like to see how I can make this faster by blazing through the connections and getting out if a connection cannot be made to a given IP within 20ms. I want to capture the actual connections in an array that I can then use for another purpose. var net = require('net'); // Required to create socket connections var ip = 254; //IP address to start with on a C class network function checkConnect () { ip--; var thisIP = '192.168.1.' + ip; //concatenate to a real IP address var S = new net.Socket(); S.connect(80, thisIP); if(ip > 0) { checkConnect(); } S.on('connect', function () { console.log('port 80 found on ' + thisIP); }); S.on('error', function () { console.log('no such port on ' + thisIP); }); S.end(); } checkConnect();
Tags (comma-separated)
Save Edits
Cancel