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

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: 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 | « no previous file | pkg/mdns/lib/mdns-sd.dart » ('j') | pkg/mdns/lib/mdns-sd.dart » ('J')
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 /// Lookup [hostname] using mDNS.
Søren Gjesse 2015/11/06 08:44:48 The comment needs to be updated.
karlklose 2015/11/06 12:19:59 Done.
48 /// 51 ///
49 /// The `hostname` must have the form `single-dns-label.local`, 52 /// The `hostname` must have the form `single-dns-label.local`,
50 /// e.g. `printer.local`. 53 /// e.g. `printer.local`.
51 /// 54 ///
52 /// If no answer has been received within the specified [timeout] 55 /// If no answer has been received within the specified [timeout]
53 /// this method will complete with the value `null`. 56 /// this method will complete with the value `null`.
54 Future<InternetAddress> lookup( 57 Stream<ResourceRecord> lookup(
55 String hostname, {Duration timeout: const Duration(seconds: 5)}); 58 int type,
59 String name,
60 {Duration timeout: const Duration(seconds: 5)});
56 } 61 }
57 62
58 // Simple standalone test. 63 // Simple standalone test.
59 Future main(List<String> args) async { 64 Future main(List<String> args) async {
60 var client = new MDnsClient(); 65 var client = new MDnsClient();
61 await client.start(); 66 await client.start();
62 var address = await client.lookup(args[0]); 67 ResourceRecord resource = await client.lookup(RRType.A, args[0]).first;
68 print(address);
63 client.stop(); 69 client.stop();
64 print(address);
65 } 70 }
OLDNEW
« no previous file with comments | « no previous file | pkg/mdns/lib/mdns-sd.dart » ('j') | pkg/mdns/lib/mdns-sd.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698