Chromium Code Reviews| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 * will lookup both IP version 4 (IPv4) and IP version 6 (IPv6) | 92 * will lookup both IP version 4 (IPv4) and IP version 6 (IPv6) |
| 93 * addresses. If [type] is either [InternetAddressType.IP_V4] or | 93 * addresses. If [type] is either [InternetAddressType.IP_V4] or |
| 94 * [InternetAddressType.IP_V6] it will only lookup addresses of the | 94 * [InternetAddressType.IP_V6] it will only lookup addresses of the |
| 95 * specified type. The order of the list can, and most likely will, | 95 * specified type. The order of the list can, and most likely will, |
| 96 * change over time. | 96 * change over time. |
| 97 */ | 97 */ |
| 98 external static Future<List<InternetAddress>> lookup( | 98 external static Future<List<InternetAddress>> lookup( |
| 99 String host, {InternetAddressType type: InternetAddressType.IP_V4}); | 99 String host, {InternetAddressType type: InternetAddressType.IP_V4}); |
| 100 } | 100 } |
| 101 | 101 |
| 102 /** | 102 /** |
|
Bill Hesse
2013/05/01 08:57:06
A [RawServerSocket] represents a listening socket,
Søren Gjesse
2013/05/01 09:06:42
Done.
| |
| 103 * The RawServerSocket is a server socket, providing a stream of low-level | 103 * The RawServerSocket is a server socket, providing a stream of low-level |
| 104 * [RawSocket]s. | 104 * [RawSocket]s. |
| 105 * | 105 * |
| 106 * See [RawSocket] for more info. | 106 * See [RawSocket] for more info. |
| 107 */ | 107 */ |
| 108 abstract class RawServerSocket implements Stream<RawSocket> { | 108 abstract class RawServerSocket implements Stream<RawSocket> { |
| 109 /** | 109 /** |
| 110 * Returns a future for a [:RawServerSocket:]. When the future | 110 * Returns a future for a [:RawServerSocket:]. When the future |
| 111 * completes the server socket is bound to the given [address] and | 111 * completes the server socket is bound to the given [address] and |
| 112 * [port] and has started listening on it. | 112 * [port] and has started listening on it. |
| 113 * | 113 * |
| 114 * The default value for [address] is 127.0.0.1, which will allow | 114 * The [address] can either be a [String] or an |
| 115 * only incoming connections from the local host. To allow for | 115 * [InternetAddress]. If [address] is a [String], [bind] will |
| 116 * incoming connection from the network use either the value 0.0.0.0 | 116 * perform a [InternetAddress.lookup] and use the first value in the |
| 117 * to bind to all interfaces or the IP address of a specific | 117 * list. To listen on the loopback adapter, which will allow only |
| 118 * interface. | 118 * incoming connections from the local host, use the value |
| 119 * [InternetAddress.LOOPBACK_IP_V4] or | |
| 120 * [InternetAddress.LOOPBACK_IP_V6]. To allow for incoming | |
| 121 * connection from the network use either one of the values | |
| 122 * [InternetAddress.ANY_IP_V4] or [InternetAddress.ANY_IP_V6] to | |
| 123 * bind to all interfaces or the IP address of a specific interface. | |
| 119 * | 124 * |
| 120 * If [port] has the value [:0:] (the default) an ephemeral port will | 125 * If an IP version 6 (IPv6) address is used, both IP version 6 |
| 126 * (IPv6) and version 4 (IPv4) connections will be accepted. To | |
| 127 * restrict this to version 6 (IPv6) only, use [setOption] to set | |
| 128 * version 6 only. | |
| 129 * | |
| 130 * If [port] has the value [:0:] an ephemeral port will | |
| 121 * be chosen by the system. The actual port used can be retrieved | 131 * be chosen by the system. The actual port used can be retrieved |
| 122 * using the [:port:] getter. | 132 * using the [:port:] getter. |
| 123 * | 133 * |
| 124 * The optional argument [backlog] can be used to specify the listen | 134 * The optional argument [backlog] can be used to specify the listen |
| 125 * backlog for the underlying OS listen setup. If [backlog] has the | 135 * backlog for the underlying OS listen setup. If [backlog] has the |
| 126 * value of [:0:] (the default) a reasonable value will be chosen by | 136 * value of [:0:] (the default) a reasonable value will be chosen by |
| 127 * the system. | 137 * the system. |
| 128 */ | 138 */ |
| 129 external static Future<RawServerSocket> bind([address = "127.0.0.1", | 139 external static Future<RawServerSocket> bind(address, |
| 130 int port = 0, | 140 int port, |
| 131 int backlog = 0]); | 141 {int backlog: 0}); |
| 132 | 142 |
| 133 /** | 143 /** |
| 134 * Returns the port used by this socket. | 144 * Returns the port used by this socket. |
| 135 */ | 145 */ |
| 136 int get port; | 146 int get port; |
| 137 | 147 |
| 138 /** | 148 /** |
| 139 * Closes the socket. | 149 * Closes the socket. |
| 140 */ | 150 */ |
| 141 void close(); | 151 void close(); |
| 142 } | 152 } |
| 143 | 153 |
| 144 | 154 |
| 145 /** | 155 /** |
| 146 * The [ServerSocket] is server socket, providing a stream of high-level | 156 * The [ServerSocket] is server socket, providing a stream of high-level |
|
Bill Hesse
2013/05/01 08:57:06
A [ServerSocket] represents a listening socket, an
Søren Gjesse
2013/05/01 09:06:42
Done.
| |
| 147 * [Socket]s. | 157 * [Socket]s. |
| 148 * | 158 * |
| 149 * See [Socket] for more info. | 159 * See [Socket] for more info. |
| 150 */ | 160 */ |
| 151 abstract class ServerSocket implements Stream<Socket> { | 161 abstract class ServerSocket implements Stream<Socket> { |
| 152 /** | 162 /** |
| 153 * Returns a future for a [:ServerSocket:]. When the future | 163 * Returns a future for a [:ServerSocket:]. When the future |
| 154 * completes the server socket is bound to the given [address] and | 164 * completes the server socket is bound to the given [address] and |
| 155 * [port] and has started listening on it. | 165 * [port] and has started listening on it. |
| 156 * | 166 * |
| 157 * The default value for [address] is 127.0.0.1, which will allow | 167 * The [address] can either be a [String] or an |
| 158 * only incoming connections from the local host. To allow for | 168 * [InternetAddress]. If [address] is a [String], [bind] will |
| 159 * incoming connection from the network use either the value 0.0.0.0 | 169 * perform a [InternetAddress.lookup] and use the first value in the |
| 160 * to bind to all interfaces or the IP address of a specific | 170 * list. To listen on the loopback adapter, which will allow only |
| 161 * interface. | 171 * incoming connections from the local host, use the value |
| 172 * [InternetAddress.LOOPBACK_IP_V4] or | |
| 173 * [InternetAddress.LOOPBACK_IP_V6]. To allow for incoming | |
| 174 * connection from the network use either one of the values | |
| 175 * [InternetAddress.ANY_IP_V4] or [InternetAddress.ANY_IP_V6] to | |
| 176 * bind to all interfaces or the IP address of a specific interface. | |
| 162 * | 177 * |
| 163 * If [port] has the value [:0:] (the default) an ephemeral port will | 178 * If an IP version 6 (IPv6) address is used, both IP version 6 |
| 164 * be chosen by the system. The actual port used can be retrieved | 179 * (IPv6) and version 4 (IPv4) connections will be accepted. To |
| 165 * using the [port] getter. | 180 * restrict this to version 6 (IPv6) only, use [setOption] to set |
| 181 * version 6 only. | |
| 182 * | |
| 183 * If [port] has the value [:0:] an ephemeral port will be chosen by | |
| 184 * the system. The actual port used can be retrieved using the | |
| 185 * [port] getter. | |
| 166 * | 186 * |
| 167 * The optional argument [backlog] can be used to specify the listen | 187 * The optional argument [backlog] can be used to specify the listen |
| 168 * backlog for the underlying OS listen setup. If [backlog] has the | 188 * backlog for the underlying OS listen setup. If [backlog] has the |
| 169 * value of [:0:] (the default) a reasonable value will be chosen by | 189 * value of [:0:] (the default) a reasonable value will be chosen by |
| 170 * the system. | 190 * the system. |
| 171 */ | 191 */ |
| 172 external static Future<ServerSocket> bind([address = "127.0.0.1", | 192 external static Future<ServerSocket> bind(address, |
| 173 int port = 0, | 193 int port, |
| 174 int backlog = 0]); | 194 {int backlog: 0}); |
| 175 | 195 |
| 176 /** | 196 /** |
| 177 * Returns the port used by this socket. | 197 * Returns the port used by this socket. |
| 178 */ | 198 */ |
| 179 int get port; | 199 int get port; |
| 180 | 200 |
| 181 /** | 201 /** |
| 182 * Closes the socket. | 202 * Closes the socket. |
| 183 */ | 203 */ |
| 184 void close(); | 204 void close(); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 396 sb.write(" ($osError)"); | 416 sb.write(" ($osError)"); |
| 397 } | 417 } |
| 398 } else if (osError != null) { | 418 } else if (osError != null) { |
| 399 sb.write(": $osError"); | 419 sb.write(": $osError"); |
| 400 } | 420 } |
| 401 return sb.toString(); | 421 return sb.toString(); |
| 402 } | 422 } |
| 403 final String message; | 423 final String message; |
| 404 final OSError osError; | 424 final OSError osError; |
| 405 } | 425 } |
| OLD | NEW |