Permalink
Browse files

added some more tutorial text

  • Loading branch information...
1 parent f94e9ce commit d44dd2ebf35760f5bbb589af641d8d0f7efa6705 @agnat agnat committed Aug 30, 2010
Showing with 30 additions and 3 deletions.
  1. +30 −3 README.textile
View
33 README.textile
@@ -4,10 +4,10 @@ node_mdns adds support for multicast DNS service discovery, also known as zeroco
Internally, it uses the mDNSResponder API which is available on all major platforms.
-h2. Build, Installation and Dependencies
-
On Linux and other systems using the avahi daemon the avahi dns_sd compat library and its header files are required.
+h2. Installation
+
node_mdns is available as a npm package. To fetch, compile and install the add-on do:
bc. npm install mdns
@@ -20,7 +20,34 @@ node-waf configure build && ./run_tests
h2. Tutorial
-Multicast DNS service discovery provides a way to announce and discover services on the local network.
+Multicast DNS service discovery provides a way to announce and discover services on the local network. Here is how to announce a HTTP server running on port 4321:
+
+bc.. var mdns = require('mdns');
+var ad = mdns.createAdvertisement('http', 4321);
+ad.start();
+
+And here is how to browse all HTTP servers on the local network:
+
+bc.. var browser = mdns.createBrowser('http');
+browser.on('serviceUp', function(info, flags) {
+ sys.puts("Up: " + sys.inspect(info));
+});
+browser.on('serviceDown', function(info, flags) {
+ sys.puts("Down: " + sys.inspect(info));
+});
+browser.start();
+
+As you can see the browser object is an EventEmitter. For each HTTP server a 'serviceUp' event is emitted. Likewise, if a server disappears 'serviceDown' is send. A 'serviceUp' info object might look like this:
+
+bc.. { interfaceIndex: 4
+, serviceName: 'somehost'
+, regtype: '_http._tcp.'
+, replyDomain: 'local.'
+, fullname: 'somehost._http._tcp.local.'
+, host: 'somehost.local.'
+, port: 4321
+, addresses: [ '10.1.1.50', 'fe80::21f:5bff:fecd:ce64' ]
+}
h2. Reference

0 comments on commit d44dd2e

Please sign in to comment.