| Index: runtime/bin/socket_patch.dart
|
| diff --git a/runtime/bin/socket_patch.dart b/runtime/bin/socket_patch.dart
|
| index 58c9ddd0547f12a6942202b8a03a54bc5f699535..daa59c6448fc629f34fc8e14f99d17e80099c26a 100644
|
| --- a/runtime/bin/socket_patch.dart
|
| +++ b/runtime/bin/socket_patch.dart
|
| @@ -3,7 +3,7 @@
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| patch class RawServerSocket {
|
| - /* patch */ static Future<RawServerSocket> bind([String address = "127.0.0.1",
|
| + /* patch */ static Future<RawServerSocket> bind([address = "127.0.0.1",
|
| int port = 0,
|
| int backlog = 0]) {
|
| return _RawServerSocket.bind(address, port, backlog);
|
| @@ -20,7 +20,7 @@ patch class RawSocket {
|
|
|
| patch class InternetAddress {
|
| /* patch */ static Future<List<InternetAddress>> lookup(
|
| - String host, {InternetAddressType type: InternetAddressType.ANY}) {
|
| + String host, {InternetAddressType type: InternetAddressType.IPv4}) {
|
| return _NativeSocket.lookup(host, type: type);
|
| }
|
| }
|
| @@ -105,7 +105,7 @@ class _NativeSocket extends NativeFieldWrapperClass1 {
|
| static SendPort socketService;
|
|
|
| static Future<List<InternetAddress>> lookup(
|
| - String host, {InternetAddressType type: InternetAddressType.ANY}) {
|
| + String host, {InternetAddressType type: InternetAddressType.IPv4}) {
|
| ensureSocketService();
|
| return socketService.call([HOST_NAME_LOOKUP, host, type._value])
|
| .then((response) {
|
| @@ -160,15 +160,19 @@ class _NativeSocket extends NativeFieldWrapperClass1 {
|
| });
|
| }
|
|
|
| - static Future<_NativeSocket> bind(String address,
|
| + static Future<_NativeSocket> bind(host,
|
| int port,
|
| int backlog) {
|
| - return lookup(address)
|
| - .then((list) {
|
| - if (list.length == 0) {
|
| - throw createError(response, "Failed host name lookup");
|
| - }
|
| - return list[0];
|
| + return new Future.value(host)
|
| + .then((host) {
|
| + if (host is _InternetAddress) return host;
|
| + return lookup(host)
|
| + .then((list) {
|
| + if (list.length == 0) {
|
| + throw createError(response, "Failed host name lookup");
|
| + }
|
| + return list[0];
|
| + });
|
| })
|
| .then((address) {
|
| var socket = new _NativeSocket.listen();
|
| @@ -486,7 +490,7 @@ class _RawServerSocket extends Stream<RawSocket>
|
| final _NativeSocket _socket;
|
| StreamController<RawSocket> _controller;
|
|
|
| - static Future<_RawServerSocket> bind(String address,
|
| + static Future<_RawServerSocket> bind(address,
|
| int port,
|
| int backlog) {
|
| if (port < 0 || port > 0xFFFF)
|
| @@ -680,7 +684,7 @@ class _RawSocket extends Stream<RawSocketEvent>
|
|
|
|
|
| patch class ServerSocket {
|
| - /* patch */ static Future<ServerSocket> bind([String address = "127.0.0.1",
|
| + /* patch */ static Future<ServerSocket> bind([address = "127.0.0.1",
|
| int port = 0,
|
| int backlog = 0]) {
|
| return _ServerSocket.bind(address, port, backlog);
|
| @@ -691,7 +695,7 @@ class _ServerSocket extends Stream<Socket>
|
| implements ServerSocket {
|
| final _socket;
|
|
|
| - static Future<_ServerSocket> bind(String address,
|
| + static Future<_ServerSocket> bind(address,
|
| int port,
|
| int backlog) {
|
| return _RawServerSocket.bind(address, port, backlog)
|
|
|