| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart 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 file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of dart.io; | 5 part of dart.io; |
| 6 | 6 |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * [InternetAddressType] is the type an [InternetAddress]. Currently, | 9 * [InternetAddressType] is the type an [InternetAddress]. Currently, |
| 10 * IP version 4 (IPv4) and IP version 6 (IPv6) are supported. | 10 * IP version 4 (IPv4) and IP version 6 (IPv6) are supported. |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 * addresses. If [type] is either [InternetAddressType.IP_V4] or | 137 * addresses. If [type] is either [InternetAddressType.IP_V4] or |
| 138 * [InternetAddressType.IP_V6] it will only lookup addresses of the | 138 * [InternetAddressType.IP_V6] it will only lookup addresses of the |
| 139 * specified type. The order of the list can, and most likely will, | 139 * specified type. The order of the list can, and most likely will, |
| 140 * change over time. | 140 * change over time. |
| 141 */ | 141 */ |
| 142 external static Future<List<InternetAddress>> lookup( | 142 external static Future<List<InternetAddress>> lookup( |
| 143 String host, {InternetAddressType type: InternetAddressType.ANY}); | 143 String host, {InternetAddressType type: InternetAddressType.ANY}); |
| 144 } | 144 } |
| 145 | 145 |
| 146 | 146 |
| 147 class UnixDomainAddress { |
| 148 final String path; |
| 149 bool get isLoopback => false; // HACK. |
| 150 UnixDomainAddress(this.path); |
| 151 } |
| 152 |
| 153 |
| 147 /** | 154 /** |
| 148 * A [NetworkInterface] represent an active network interface on the current | 155 * A [NetworkInterface] represent an active network interface on the current |
| 149 * system. It contains a list of [InternetAddress]s, that's bound to the | 156 * system. It contains a list of [InternetAddress]s, that's bound to the |
| 150 * interface. | 157 * interface. |
| 151 */ | 158 */ |
| 152 abstract class NetworkInterface { | 159 abstract class NetworkInterface { |
| 153 /** | 160 /** |
| 154 * Get the name of the [NetworkInterface]. | 161 * Get the name of the [NetworkInterface]. |
| 155 */ | 162 */ |
| 156 String get name; | 163 String get name; |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 * If an error occur when trying to join the multicase group an | 759 * If an error occur when trying to join the multicase group an |
| 753 * exception is thrown. | 760 * exception is thrown. |
| 754 */ | 761 */ |
| 755 void leaveMulticast(InternetAddress group, {NetworkInterface interface}); | 762 void leaveMulticast(InternetAddress group, {NetworkInterface interface}); |
| 756 } | 763 } |
| 757 | 764 |
| 758 | 765 |
| 759 class SocketException implements IOException { | 766 class SocketException implements IOException { |
| 760 final String message; | 767 final String message; |
| 761 final OSError osError; | 768 final OSError osError; |
| 762 final InternetAddress address; | 769 final /* InternetAddress or UnixDomainAddress */ address; |
| 763 final int port; | 770 final int port; |
| 764 | 771 |
| 765 const SocketException(this.message, {this.osError, this.address, this.port}); | 772 const SocketException(this.message, {this.osError, this.address, this.port}); |
| 766 const SocketException.closed() | 773 const SocketException.closed() |
| 767 : message = 'Socket has been closed', | 774 : message = 'Socket has been closed', |
| 768 osError = null, | 775 osError = null, |
| 769 address = null, | 776 address = null, |
| 770 port = null; | 777 port = null; |
| 771 | 778 |
| 772 String toString() { | 779 String toString() { |
| 773 StringBuffer sb = new StringBuffer(); | 780 StringBuffer sb = new StringBuffer(); |
| 774 sb.write("SocketException"); | 781 sb.write("SocketException"); |
| 775 if (!message.isEmpty) { | 782 if (!message.isEmpty) { |
| 776 sb.write(": $message"); | 783 sb.write(": $message"); |
| 777 if (osError != null) { | 784 if (osError != null) { |
| 778 sb.write(" ($osError)"); | 785 sb.write(" ($osError)"); |
| 779 } | 786 } |
| 780 } else if (osError != null) { | 787 } else if (osError != null) { |
| 781 sb.write(": $osError"); | 788 sb.write(": $osError"); |
| 782 } | 789 } |
| 783 if (address != null) { | 790 if (address != null) { |
| 784 sb.write(", address = ${address.host}"); | 791 sb.write(", address = ${address.host}"); |
| 785 } | 792 } |
| 786 if (port != null) { | 793 if (port != null) { |
| 787 sb.write(", port = $port"); | 794 sb.write(", port = $port"); |
| 788 } | 795 } |
| 789 return sb.toString(); | 796 return sb.toString(); |
| 790 } | 797 } |
| 791 } | 798 } |
| OLD | NEW |