Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(413)

Unified Diff: pkg/mdns/bin/mdns-resolve.dart

Issue 1432973002: Update the mDNS command line tools in the mdns package (Closed) Base URL: git@github.com:dart-lang/fletch.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/mdns/bin/mdns-sd.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/mdns/bin/mdns-resolve.dart
diff --git a/pkg/mdns/bin/mdns-resolve.dart b/pkg/mdns/bin/mdns-resolve.dart
new file mode 100644
index 0000000000000000000000000000000000000000..45dc9378f8358913470c90c202074cba6a92bdc9
--- /dev/null
+++ b/pkg/mdns/bin/mdns-resolve.dart
@@ -0,0 +1,38 @@
+// Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE.md file.
+
+// Example script to illustrate how to use the mdns package to lookup names
+// on the local network.
+
+import 'package:args/args.dart';
+
+import '../lib/mdns.dart';
+
+main(List<String> args) async {
+ // Parse the command line arguments.
+ var parser = new ArgParser();
+ parser.addOption('timeout', abbr: 't', defaultsTo: '5');
+ var arguments = parser.parse(args);
+
+ if (arguments.rest.length != 1) {
+ print('''
+Please provide an address as argument.
+
+For example:
+ dart mdns-resolve.dart [--timeout <timeout>] fletch.local''');
+ return;
+ }
+
+ var name = arguments.rest[0];
+
+ MDnsClient client = new MDnsClient();
+ await client.start();
+ var timeout;
+ timeout = new Duration(seconds: int.parse(arguments['timeout']));
+ await for (ResourceRecord record in
+ client.lookup(RRType.A, name, timeout: timeout)) {
+ print('Found address (${record.address}).');
+ }
+ client.stop();
+}
« no previous file with comments | « no previous file | pkg/mdns/bin/mdns-sd.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698