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

Unified Diff: sdk/lib/io/socket.dart

Issue 16514010: Add NetworkAdaptor to dart:io. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Clean up implementation and add tests. Created 7 years, 6 months 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: sdk/lib/io/socket.dart
diff --git a/sdk/lib/io/socket.dart b/sdk/lib/io/socket.dart
index 040cf39424f06e9ae15935757477026970d4b65d..f272262f4f74b48dc80abb27d58c22dc902df81c 100644
--- a/sdk/lib/io/socket.dart
+++ b/sdk/lib/io/socket.dart
@@ -87,6 +87,16 @@ abstract class InternetAddress {
String get host;
/**
+ * Returns true if the [InternetAddress] is a loopback address.
+ */
+ bool get isLoopback;
+
+ /**
+ * Returns true if the [InternetAddress]s scope is a link-local.
+ */
+ bool get isLinkLocal;
+
+ /**
* Lookup a host, returning a Future of a list of
* [InternetAddress]s. If [type] is [InternetAddressType.ANY], it
* will lookup both IP version 4 (IPv4) and IP version 6 (IPv6)
@@ -99,6 +109,44 @@ abstract class InternetAddress {
String host, {InternetAddressType type: InternetAddressType.ANY});
}
+
+/**
+ * A [NetworkInterface] represent an active network interface on the current
+ * system. It contains a list of [InternetAddress]s, that's bound to the
+ * interface.
+ */
+class NetworkInterface {
+ /**
+ * Get the name of the [NetworkInterface].
+ */
+ String get name;
+
+ /**
+ * Get a list of [InternetAddress]s currently bound to this
+ * [NetworkInterface].
+ */
+ List<InternetAddress> get addresses;
+
+ /**
+ * Query the system for [NetworkInterface]s.
+ *
+ * If [includeLoopback] is `true`, the returned list will include the
+ * loopback device. Default is `false`.
+ *
+ * If [includeLinkLocal] is `true`, the list of addresses of the returned
+ * [NetworkInterface]s, may include link local addresses. Default is `false`.
+ *
+ * If [type] is either [InternetAddressType.IP_V4] or
+ * [InternetAddressType.IP_V6] it will only lookup addresses of the
+ * specified type. Default is [InternetAddressType.ANY].
+ */
+ external static Future<List<NetworkInterface>> list({
+ bool includeLoopback: false,
+ bool includeLinkLocal: false,
+ InternetAddressType type: InternetAddressType.ANY});
+}
+
+
/**
* A [RawServerSocket] represents a listening socket, and provides a
* stream of low-level [RawSocket] objects, one for each connection

Powered by Google App Engine
This is Rietveld 408576698