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

Unified Diff: runtime/bin/socket_patch.dart

Issue 17640008: Add reverse dns lookup as a method on InternetAddress. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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: runtime/bin/socket_patch.dart
diff --git a/runtime/bin/socket_patch.dart b/runtime/bin/socket_patch.dart
index 3caf14806bc3f7f152d4248485e0a1a3ce8479a9..7c3069a7a0c8e7e710eda4abbf059952c453eea2 100644
--- a/runtime/bin/socket_patch.dart
+++ b/runtime/bin/socket_patch.dart
@@ -104,6 +104,8 @@ class _InternetAddress implements InternetAddress {
}
}
+ Future<InternetAddress> reverse() => _NativeSocket.reverseLookup(this);
+
_InternetAddress(InternetAddressType this.type,
String this.address,
String this.host,
@@ -191,6 +193,7 @@ class _NativeSocket extends NativeFieldWrapperClass1 {
// Native port messages.
static const HOST_NAME_LOOKUP = 0;
static const LIST_INTERFACES = 1;
+ static const REVERSE_LOOKUP = 2;
// Socket close state
bool isClosed = false;
@@ -234,6 +237,18 @@ class _NativeSocket extends NativeFieldWrapperClass1 {
});
}
+ static Future<InternetAddress> reverseLookup(InternetAddress addr) {
+ ensureSocketService();
+ return socketService.call([REVERSE_LOOKUP, addr._sockaddr_storage])
+ .then((response) {
+ if (isErrorResponse(response)) {
+ throw createError(response, "Failed host name lookup");
+ } else {
+ return addr._cloneWithNewHost(response);
+ }
+ });
+ }
+
static Future<List<NetworkInterface>> listInterfaces({
bool includeLoopback: false,
bool includeLinkLocal: false,

Powered by Google App Engine
This is Rietveld 408576698