title: Device/ Computer Discovery in my Network
body: <p>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 <a href="https://gist.github.com/chrishulbert/895382">https://gist.github.com/chrishulbert/895382</a> 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.</p>
  
  <pre><code>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); 
  
  }
  
  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();
  </code></pre>