Permalink
Browse files

fix discover udp logic

  • Loading branch information...
1 parent 3c8904f commit 362f64af93a7bed79af7b3f9e7f928f8fe489d1b @mharsch committed Mar 7, 2013
Showing with 7 additions and 3 deletions.
  1. +7 −3 discover.js
View
@@ -51,8 +51,12 @@ module.exports = function (search_id, cb) {
parseInt(search_id, 16)});
disc_pkt = proto.encode_msg(disc_msg);
- sock.send(disc_pkt, 0, disc_pkt.length, 65001, '255.255.255.255',
- function (err, bytes) {
- if (err) throw new Error('problem sending discover req dgram');
+ sock.on('listening', function () {
+ sock.setBroadcast(true);
+ sock.send(disc_pkt, 0, disc_pkt.length, 65001, '255.255.255.255',
+ function (err, bytes) {
+ if (err) throw new Error('problem sending discover req');
+ });
});
+ sock.bind();
}

0 comments on commit 362f64a

Please sign in to comment.