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

Side by Side Diff: pkg/mdns/lib/mdns.dart

Issue 1412063015: Improve resource record implementation in the mdns package. (Closed) Base URL: https://github.com/dart-lang/fletch.git@master
Patch Set: Remove unnecessary await. 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 unified diff | Download patch
« no previous file with comments | « pkg/mdns/bin/mdns-sd.dart ('k') | pkg/mdns/lib/src/constants.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 library mdns; 5 library mdns;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'dart:typed_data'; 10 import 'dart:typed_data';
11 11
12 import 'package:mdns/src/native_extension_client.dart'; 12 import 'package:mdns/src/native_extension_client.dart';
13 import 'package:mdns/src/native_protocol_client.dart'; 13 import 'package:mdns/src/native_protocol_client.dart';
14 import 'package:mdns/src/constants.dart';
15
16 export 'package:mdns/src/constants.dart' show RRType;
14 17
15 /// Client for DNS lookup using the mDNS protocol. 18 /// Client for DNS lookup using the mDNS protocol.
16 /// 19 ///
17 /// This client only support "One-Shot Multicast DNS Queries" as described in 20 /// This client only support "One-Shot Multicast DNS Queries" as described in
18 /// section 5.1 of https://tools.ietf.org/html/rfc6762 21 /// section 5.1 of https://tools.ietf.org/html/rfc6762
19 abstract class MDnsClient { 22 abstract class MDnsClient {
20 // Instantiate Client for DNS lookup using the mDNS protocol. 23 // Instantiate Client for DNS lookup using the mDNS protocol.
21 // 24 //
22 // On Mac OS a native extension is used as the mDNSResponder opens the mDNS 25 // On Mac OS a native extension is used as the mDNSResponder opens the mDNS
23 // port in exclusive mode. To test the protocol implementation on Mac OS 26 // port in exclusive mode. To test the protocol implementation on Mac OS
(...skipping 13 matching lines...) Expand all
37 return new NativeProtocolMDnsClient(); 40 return new NativeProtocolMDnsClient();
38 } 41 }
39 } 42 }
40 43
41 /// Start the mDNS client. 44 /// Start the mDNS client.
42 Future start(); 45 Future start();
43 46
44 /// Stop the mDNS client. 47 /// Stop the mDNS client.
45 void stop(); 48 void stop();
46 49
47 /// Lookup [hostname] using mDNS. 50 /// Query resource records with name [name] and type [type].
48 /// 51 ///
49 /// The `hostname` must have the form `single-dns-label.local`, 52 /// The [name] must be the fully qualified name (that is including
50 /// e.g. `printer.local`. 53 /// the domain '.local'); for example `printer.local`.
51 /// 54 ///
52 /// If no answer has been received within the specified [timeout] 55 /// The stream is closed after the timeout is reached.
53 /// this method will complete with the value `null`. 56 Stream<ResourceRecord> lookup(
54 Future<InternetAddress> lookup( 57 int type,
55 String hostname, {Duration timeout: const Duration(seconds: 5)}); 58 String name,
59 {Duration timeout: const Duration(seconds: 5)});
56 } 60 }
57 61
58 // Simple standalone test. 62 // Simple standalone test.
59 Future main(List<String> args) async { 63 Future main(List<String> args) async {
60 var client = new MDnsClient(); 64 var client = new MDnsClient();
61 await client.start(); 65 await client.start();
62 var address = await client.lookup(args[0]); 66 ResourceRecord resource = await client.lookup(RRType.A, args[0]).first;
67 print(address);
63 client.stop(); 68 client.stop();
64 print(address);
65 } 69 }
OLDNEW
« no previous file with comments | « pkg/mdns/bin/mdns-sd.dart ('k') | pkg/mdns/lib/src/constants.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698