From d839f43beb301da3e3e0010182916661e052de75 Mon Sep 17 00:00:00 2001 From: Daplie Date: Fri, 13 Jan 2017 16:36:01 -0700 Subject: [PATCH] first commit --- dns_test | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 dns_test diff --git a/dns_test b/dns_test new file mode 100644 index 0000000..acba7a9 --- /dev/null +++ b/dns_test @@ -0,0 +1,25 @@ +'use strict'; + +var dgram = require('dgram'); +var dnsjs = require('dns-js'); + +// SO_REUSEADDR and SO_REUSEPORT are set because +// the system mDNS Responder may already be listening on this port + +var socket = dgram.createSocket({ + type: 'udp4' +, reuseAddr: true +}); + +var broadcast = '224.0.0.251'; // mdns +var port = 5353; // mdns + +socket.bind(port, function () { + console.log('bound on', port); + + // mDNS must listen on the broadcast membership group address + socket.setBroadcast(true); + socket.addMembership(broadcast); + + // ... more stuff +}); \ No newline at end of file