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

Unified Diff: pkg/mdns/lib/mdns-sd.dart

Issue 1412063015: Improve resource record implementation in the mdns package. (Closed) Base URL: https://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
Index: pkg/mdns/lib/mdns-sd.dart
diff --git a/pkg/mdns/lib/mdns-sd.dart b/pkg/mdns/lib/mdns-sd.dart
new file mode 100644
index 0000000000000000000000000000000000000000..2e17f22ddb2500d71135c09254ec81d5a82adb5f
--- /dev/null
+++ b/pkg/mdns/lib/mdns-sd.dart
@@ -0,0 +1,31 @@
+// Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file
Søren Gjesse 2015/11/06 08:44:48 Maybe move this into ../bin.
karlklose 2015/11/06 12:19:59 Done.
+// 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 discover services
+// on the local network.
+
+import 'mdns.dart';
+
+main(List<String> args) async {
+ if (args.length != 1) {
+ print('''
+Please provide the name of a service as argument.
+
+For example:
+ dart mdns-sd.dat _workstation._tcp.local''');
+ return;
+ }
+ MDnsClient client = new MDnsClient();
+ await client.start();
+ await for (ResourceRecord ptr in client.lookup(RRType.PTR, args[0])) {
+ 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).');
+ }
+ }
+ }
+ client.stop();
+}

Powered by Google App Engine
This is Rietveld 408576698