I was trying to write a sample program for my test project to find out all 
the devices(like android or IOS) or other computers connected to the 
network to which my computer is connected.
I am able to see all the connected devices when I login to the router 
administration console and I want the same list using my program.
I tried the sample code below  which I came across the post at 
https://gist.github.com/chrishulbert/895382 and found it interesting and 
tried to use it, But i was not able to get the list. Am I missing something 
in the below code or this is a wrong sample I am referring to?. Any help 
would be greatly appreciated in this regard.

*The Code*
// Listen for responses
function listen(port) {
var server = dgram.createSocket("udp4");
server.on("message", function (msg, rinfo) {
console.log("server got: " + msg + " from " + rinfo.address + ":" + 
rinfo.port);
});
server.bind(port); 

// setTimeout(function(){
// console.log("Finished waiting");
// server.close();
// },10000);
}
 
function search() {
var message = new Buffer(
"M-SEARCH * HTTP/1.1\r\n" +
"HOST:239.255.255.250:1900\r\n" +
"MAN:\"ssdp:discover\"\r\n" +
"ST:ssdp:all\r\n" + 
"MX:3\r\n" + 
"\r\n"
);
 
var client = dgram.createSocket("udp4");
client.bind(0,"",function() {
console.log(client.address().port);
listen(client.address().port);
client.send(message, 0, message.length, 1900, "239.255.255.250",function() {
// client.close();
});
}); // So that we get a port so we can listen before sending
}
search();

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/ebc7a5e0-8cbb-44d8-83db-e20b5857b408%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to