Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

mdns

agnat15.6k2.7.2TypeScript support: definitely-typed

multicast DNS service discovery

zeroconf, bonjour, dns_sd, mDNSResponder

readme

mdns -- node.js Service Discovery

  • Package: mdns
  • Description: multicast DNS service discovery
  • Installation: npm install mdns (see below)
  • Documentation: mdns user guide
  • License: MIT
  • Donations: Flattr this git repository

mdns adds multicast DNS service discovery, also known as zeroconf or bonjour to Node.js. It provides an object based interface to announce and browse services on the local network.

Synopsis

// import the module
const mdns = require('mdns');

// advertise a http server on port 4321
const ad = mdns.createAdvertisement(mdns.tcp('http'), 4321);
ad.start();

// watch all http servers
const browser = mdns.createBrowser(mdns.tcp('http'));
browser.on('serviceUp', service => {
  console.log("service up: ", service);
});
browser.on('serviceDown', service => {
  console.log("service down: ", service);
});
browser.start();

// discover all available service types
const all_the_types = mdns.browseThemAll(); // all_the_types is just another browser...

Installation

On Linux and other systems using the avahi daemon the avahi dns_sd compat library and its header files are required. On debianesque systems the package name is libavahi-compat-libdnssd-dev, on fedoraesque systems the package is avahi-compat-libdns_sd-devel. On other platforms Apple's mDNSResponder is recommended. Care should be taken not to install more than one mDNS stack on a system.

On Windows you are going to need Apples "Bonjour SDK for Windows". You can download it either from Apple (registration required) or various unofficial sources. Take your pick. After installing the SDK restart your computer and make sure the BONJOUR_SDK_HOME environment variable is set. You'll also need a compiler. Microsoft Visual Studio Express will do. On Windows node >=0.7.9 is required.

mdns is available as a npm package:

npm install mdns

If you want to play with the latest source code, here is a more manual approach:

git clone http://github.com/agnat/node_mdns
cd node_mdns
npm link && npm test

In case you want to run or even publish your package using the development version of mdns you may set the version field to a tarball URL:

{ "name": "discomvobulator"
, "version": "0.0.1"
, "description": "covers all your discomvobulation needs"
, "dependencies":
  { "mdns": "https://github.com/agnat/node_mdns/tarball/master"
  }
}

Documentation

See the user guide.

Contributors

In random order:

Your name is missing on the list? Shame on me. Please open an issue.

Bugs and Contributions

If you find a bug, please report it using the issue tracker.

changelog

CHANGES

Version 2.2.3 to 2.2.4

  • changed Readme from textile to markdown, since npmjs.org doesn't render textfile well (ronkorving)

Version 2.2.2 to 2.2.3

  • errors that could be thrown asynchronously are now emitted as "error" (achingbrain)

Version 2.2.1 to 2.2.2

  • node-mdns now uses NAN for compatibility across a wide range of Node.js versions (incl 0.11) (donpark)

Version 2.2.0 to 2.2.1

  • changed uncatchable error into "error" event on the browser (marcooliveira)

Version 2.1.4 to 2.2.0

  • moved the repository back from Wizcorp/node_mdns to agnat/node_mdns

Version 2.1.3 to 2.1.4

  • added service to errors from the resolver (bjornstar)

Version 2.1.2 to 2.1.3

  • applied the fix from 2.1.0 to remaining parts of the code base (achingbrain)

Version 2.1.1 to 2.1.2

  • fixed an exception that was thrown when a service went down along with its network interface (achingbrain)

Version 2.1.0 to 2.1.1

  • fixed the interfaceIndex patch by mrose17 as it was breaking on Node 0.8 (ronkorving)

Version 2.0.0-dev to 2.1.0

  • errno was broken in Node v0.10 (mrose17)
  • allow interfaceIndex to be "really big" (mrose17)

Version 1.1.0 to 2.0.0-dev

  • empty version release (agnat)

Version 1.0.0 to 1.1.0

  • better handling of network interfaces
  • error handling: exceptions/errors contain the numeric error code now

Version 0.0.7 to 1.0.0

  • replaced IOWatcher with a libuv based SocketWatcher (Tony Ealden)
  • fixed an API typo: filterAdresses -> filterAddresses (major version bumped)
  • first release that actually works on windows

Version 0.0.6 to 0.0.7

  • Bugfix: convert NULL strings to undefined values in callbacks

Version 0.0.5 to 0.0.6

  • use node-gyp in gyp based builds
  • prepared a windows port

Version 0.0.4 to 0.0.5

  • Publish and receive TXT records

  • Build universal binaries on Mac OS This helps to work around a architecture mismatch between gyp-build nodes and waf-build addons.

  • Added experimental gyp-based build

  • Continuous integration and coverage testing.

  • Fixed FreeBSD build

Version 0.0.3 to 0.0.4

  • New service type objects: The strings have been replaced with a small ServiceType object. Also, older versions used TCP as the default protocol. The protocol is now mandatory. However, the new syntax is much more flexible. See user guide at http://agnat.github.com/node_mdns/user_guide.html#service_types.

  • The 'info' object is now called 'service'

  • The info.regtype property is now called service.type

  • The info.serviceName property is now called service.name

  • Callback signature changed: flags is now a property of the service object (service.flags)

  • possibly more

vim: spell spelllang=en_us :