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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 [port] has the value [:0:] an ephemeral port will |
121 * be chosen by the system. The actual port used can be retrieved | 126 * be chosen by the system. The actual port used can be retrieved |
122 * using the [:port:] getter. | 127 * using the [:port:] getter. |
123 * | 128 * |
124 * The optional argument [backlog] can be used to specify the listen | 129 * The optional argument [backlog] can be used to specify the listen |
125 * backlog for the underlying OS listen setup. If [backlog] has the | 130 * backlog for the underlying OS listen setup. If [backlog] has the |
126 * value of [:0:] (the default) a reasonable value will be chosen by | 131 * value of [:0:] (the default) a reasonable value will be chosen by |
127 * the system. | 132 * the system. |
128 */ | 133 */ |
129 external static Future<RawServerSocket> bind([address = "127.0.0.1", | 134 external static Future<RawServerSocket> bind(address, |
130 int port = 0, | 135 int port, |
131 int backlog = 0]); | 136 {int backlog: 0}); |
132 | 137 |
133 /** | 138 /** |
134 * Returns the port used by this socket. | 139 * Returns the port used by this socket. |
135 */ | 140 */ |
136 int get port; | 141 int get port; |
137 | 142 |
138 /** | 143 /** |
139 * Closes the socket. | 144 * Closes the socket. |
140 */ | 145 */ |
141 void close(); | 146 void close(); |
142 } | 147 } |
143 | 148 |
144 | 149 |
145 /** | 150 /** |
146 * The [ServerSocket] is server socket, providing a stream of high-level | 151 * The [ServerSocket] is server socket, providing a stream of high-level |
147 * [Socket]s. | 152 * [Socket]s. |
148 * | 153 * |
149 * See [Socket] for more info. | 154 * See [Socket] for more info. |
150 */ | 155 */ |
151 abstract class ServerSocket implements Stream<Socket> { | 156 abstract class ServerSocket implements Stream<Socket> { |
152 /** | 157 /** |
153 * Returns a future for a [:ServerSocket:]. When the future | 158 * Returns a future for a [:ServerSocket:]. When the future |
154 * completes the server socket is bound to the given [address] and | 159 * completes the server socket is bound to the given [address] and |
155 * [port] and has started listening on it. | 160 * [port] and has started listening on it. |
156 * | 161 * |
157 * The default value for [address] is 127.0.0.1, which will allow | 162 * The [address] can either be a [String] or an |
158 * only incoming connections from the local host. To allow for | 163 * [InternetAddress]. If [address] is a [String], [bind] will |
159 * incoming connection from the network use either the value 0.0.0.0 | 164 * perform a [InternetAddress.lookup] and use the first value in the |
160 * to bind to all interfaces or the IP address of a specific | 165 * list. To listen on the loopback adapter, which will allow only |
161 * interface. | 166 * incoming connections from the local host, use the value |
| 167 * [InternetAddress.LOOPBACK_IP_V4] or |
| 168 * [InternetAddress.LOOPBACK_IP_V6]. To allow for incoming |
| 169 * connection from the network use either one of the values |
| 170 * [InternetAddress.ANY_IP_V4] or [InternetAddress.ANY_IP_V6] to |
| 171 * bind to all interfaces or the IP address of a specific interface. |
162 * | 172 * |
163 * If [port] has the value [:0:] (the default) an ephemeral port will | 173 * If [port] has the value [:0:] an ephemeral port will be chosen by |
164 * be chosen by the system. The actual port used can be retrieved | 174 * the system. The actual port used can be retrieved using the |
165 * using the [port] getter. | 175 * [port] getter. |
166 * | 176 * |
167 * The optional argument [backlog] can be used to specify the listen | 177 * The optional argument [backlog] can be used to specify the listen |
168 * backlog for the underlying OS listen setup. If [backlog] has the | 178 * backlog for the underlying OS listen setup. If [backlog] has the |
169 * value of [:0:] (the default) a reasonable value will be chosen by | 179 * value of [:0:] (the default) a reasonable value will be chosen by |
170 * the system. | 180 * the system. |
171 */ | 181 */ |
172 external static Future<ServerSocket> bind([address = "127.0.0.1", | 182 external static Future<ServerSocket> bind(address, |
173 int port = 0, | 183 int port, |
174 int backlog = 0]); | 184 {int backlog: 0}); |
175 | 185 |
176 /** | 186 /** |
177 * Returns the port used by this socket. | 187 * Returns the port used by this socket. |
178 */ | 188 */ |
179 int get port; | 189 int get port; |
180 | 190 |
181 /** | 191 /** |
182 * Closes the socket. | 192 * Closes the socket. |
183 */ | 193 */ |
184 void close(); | 194 void close(); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 sb.write(" ($osError)"); | 406 sb.write(" ($osError)"); |
397 } | 407 } |
398 } else if (osError != null) { | 408 } else if (osError != null) { |
399 sb.write(": $osError"); | 409 sb.write(": $osError"); |
400 } | 410 } |
401 return sb.toString(); | 411 return sb.toString(); |
402 } | 412 } |
403 final String message; | 413 final String message; |
404 final OSError osError; | 414 final OSError osError; |
405 } | 415 } |
OLD | NEW |