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

Unified Diff: pkg/mdns/bin/mdns-sd.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 | « pkg/mdns/bin/mdns-resolve.dart ('k') | pkg/mdns/lib/mdns.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/mdns/bin/mdns-sd.dart
diff --git a/pkg/mdns/bin/mdns-sd.dart b/pkg/mdns/bin/mdns-sd.dart
index 1357aa71e43f9ac5851a244f219300699be5fbc5..6310626ff6e477f49e9d4be7ce5a5d76e3587489 100644
--- a/pkg/mdns/bin/mdns-sd.dart
+++ b/pkg/mdns/bin/mdns-sd.dart
@@ -5,25 +5,35 @@
// Example script to illustrate how to use the mdns package to discover services
// on the local network.
-import 'mdns.dart';
+import 'package:args/args.dart';
+
+import '../lib/mdns.dart';
main(List<String> args) async {
- if (args.length != 1) {
+ // 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 the name of a service as argument.
For example:
- dart mdns-sd.dart _workstation._tcp.local''');
+ dart mdns-sd.dart [--timeout <timeout>] _workstation._tcp.local''');
return;
}
+
+ var name = arguments.rest[0];
+
MDnsClient client = new MDnsClient();
await client.start();
- await for (ResourceRecord ptr in client.lookup(RRType.PTR, args[0])) {
+ await for (ResourceRecord ptr in client.lookup(RRType.PTR, name)) {
String domain = ptr.domainName;
await for (ResourceRecord srv in client.lookup(RRType.SRV, domain)) {
String target = srv.target;
await for (ResourceRecord ip in client.lookup(RRType.A, target)) {
- print('Service instance found at $target ($ip).');
+ print('Service instance found at $target (${ip.address}).');
}
}
}
« no previous file with comments | « pkg/mdns/bin/mdns-resolve.dart ('k') | pkg/mdns/lib/mdns.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698