diff --git a/lib/client.js b/lib/client.js index bc0d53b..24a1571 100644 --- a/lib/client.js +++ b/lib/client.js @@ -73,26 +73,25 @@ module.exports = function(options) { } } - addresses = [addresses[1]]; - // Performs broadcast discovery on each interface addresses.forEach(function(address) { // Sets up a broadcast socket var socket = dgram.createSocket('udp4'); - socket.bind(self.localPorts.discovery, address); - socket.setBroadcast(true); - - // Sends the broadcast discover command - var buffer = commandManager.encode('broadcastDiscover', self.deviceSettings); - socket.send(buffer, 0, buffer.length, self.remotePorts.discovery, "255.255.255.255"); - socket.on('message', function(buffer, info) { - // Recieves the command and fulfills the promise - var response = commandManager.decode(buffer); - response.remoteAddress = info.address; - response.localAddress = address; - self.devices[response.serialNumber] = response; - deferred.resolve(response.serialNumber); - socket.close(); + socket.bind(self.localPorts.discovery, address, function () { + socket.setBroadcast(true); + + // Sends the broadcast discover command + var buffer = commandManager.encode('broadcastDiscover', self.deviceSettings); + socket.send(buffer, 0, buffer.length, self.remotePorts.discovery, "255.255.255.255"); + socket.on('message', function(buffer, info) { + // Recieves the command and fulfills the promise + var response = commandManager.decode(buffer); + response.remoteAddress = info.address; + response.localAddress = address; + self.devices[response.serialNumber] = response; + deferred.resolve(response.serialNumber); + socket.close(); + }); }); })