Index: pkg/mdns/lib/src/native_protocol_client.dart |
diff --git a/pkg/mdns/lib/mdns.dart b/pkg/mdns/lib/src/native_protocol_client.dart |
similarity index 74% |
copy from pkg/mdns/lib/mdns.dart |
copy to pkg/mdns/lib/src/native_protocol_client.dart |
index f707136d4c865cb33b8b6f39c022af0af5fbd5f7..23854300ee9281e44c4dac70c3755474579346bb 100644 |
--- a/pkg/mdns/lib/mdns.dart |
+++ b/pkg/mdns/lib/src/native_protocol_client.dart |
@@ -1,21 +1,20 @@ |
-// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
+// 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 file. |
+// BSD-style license that can be found in the LICENSE.md file. |
+ |
+library mdns.src.native_protocol_client; |
import 'dart:async'; |
import 'dart:collection'; |
import 'dart:io'; |
-import 'dart:typed_data'; |
+import 'package:mdns/mdns.dart'; |
import 'package:mdns/src/constants.dart'; |
import 'package:mdns/src/lookup_resolver.dart'; |
import 'package:mdns/src/packet.dart'; |
-/// Client for DNS lookup using the mDNS protocol. |
-/// |
-/// This client only support "One-Shot Multicast DNS Queries" as described in |
-/// section 5.1 of https://tools.ietf.org/html/rfc6762 |
-class MDnsClient { |
+// Implementation of mDNS client using the native protocol. |
+class NativeProtocolMDnsClient implements MDnsClient { |
bool _starting = false; |
bool _started = false; |
RawDatagramSocket _incoming; |
@@ -51,7 +50,6 @@ class MDnsClient { |
_started = true; |
} |
- /// Stop the mDNS client. |
void stop() { |
if (!_started) return; |
if (_starting) { |
@@ -64,13 +62,6 @@ class MDnsClient { |
_started = false; |
} |
- /// Lookup [hostname] using mDNS. |
- /// |
- /// The `hostname` must have the form `single-dns-label.local`, |
- /// e.g. `printer.local`. |
- /// |
- /// If no answer has been received within the specified [timeout] |
- /// this method will complete with the value `null`. |
Future<InternetAddress> lookup( |
String hostname, {Duration timeout: const Duration(seconds: 5)}) { |
if (!_started) { |
@@ -100,12 +91,3 @@ class MDnsClient { |
} |
} |
} |
- |
-// Simple standalone test. |
-main() async { |
- var client = new MDnsClient(); |
- await client.start(); |
- var address = await client.lookup('raspberrypi.local'); |
- client.stop(); |
- print(address); |
-} |