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 | |
8 class InternetAddressType { | |
9 static const InternetAddressType IPv4 = const InternetAddressType._("IPv4"); | |
10 static const InternetAddressType IPv6 = const InternetAddressType._("IPv6"); | |
Søren Gjesse
2013/04/18 09:07:40
Change this to an integer with the same values as
Anders Johnsen
2013/04/18 12:09:45
Done.
| |
11 final String name; | |
12 const InternetAddressType._(String this.name); | |
Søren Gjesse
2013/04/18 09:07:40
Please ass toString as well.
Anders Johnsen
2013/04/18 12:09:45
Done.
| |
13 } | |
14 | |
15 abstract class InternetAddress { | |
16 InternetAddressType type; | |
17 String get address; | |
18 | |
19 external static Future<List<InternetAddress>> lookup(String host); | |
20 } | |
21 | |
7 /** | 22 /** |
8 * The RawServerSocket is a server socket, providing a stream of low-level | 23 * The RawServerSocket is a server socket, providing a stream of low-level |
9 * [RawSocket]s. | 24 * [RawSocket]s. |
10 * | 25 * |
11 * See [RawSocket] for more info. | 26 * See [RawSocket] for more info. |
12 */ | 27 */ |
13 abstract class RawServerSocket implements Stream<RawSocket> { | 28 abstract class RawServerSocket implements Stream<RawSocket> { |
14 /** | 29 /** |
15 * Returns a future for a [:RawServerSocket:]. When the future | 30 * Returns a future for a [:RawServerSocket:]. When the future |
16 * completes the server socket is bound to the given [address] and | 31 * completes the server socket is bound to the given [address] and |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 } | 151 } |
137 | 152 |
138 /** | 153 /** |
139 * The [RawSocket] is a low-level interface to a socket, exposing the raw | 154 * The [RawSocket] is a low-level interface to a socket, exposing the raw |
140 * events signaled by the system. It's a [Stream] of [RawSocketEvent]s. | 155 * events signaled by the system. It's a [Stream] of [RawSocketEvent]s. |
141 */ | 156 */ |
142 abstract class RawSocket implements Stream<RawSocketEvent> { | 157 abstract class RawSocket implements Stream<RawSocketEvent> { |
143 /** | 158 /** |
144 * Creates a new socket connection to the host and port and returns a [Future] | 159 * Creates a new socket connection to the host and port and returns a [Future] |
145 * that will complete with either a [RawSocket] once connected or an error | 160 * that will complete with either a [RawSocket] once connected or an error |
146 * if the host-lookup or connection failed. | 161 * if the host-lookup or connection failed. |
Søren Gjesse
2013/04/18 09:07:40
Update comment on type of host.
Anders Johnsen
2013/04/18 12:09:45
Done.
| |
147 */ | 162 */ |
148 external static Future<RawSocket> connect(String host, int port); | 163 external static Future<RawSocket> connect(host, int port); |
149 | 164 |
150 /** | 165 /** |
151 * Returns the number of received and non-read bytes in the socket that | 166 * Returns the number of received and non-read bytes in the socket that |
152 * can be read. | 167 * can be read. |
153 */ | 168 */ |
154 int available(); | 169 int available(); |
155 | 170 |
156 /** | 171 /** |
157 * Read up to [len] bytes from the socket. This function is | 172 * Read up to [len] bytes from the socket. This function is |
158 * non-blocking and will only return data if data is available. The | 173 * non-blocking and will only return data if data is available. The |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
225 | 240 |
226 /** | 241 /** |
227 * A high-level class for communicating over a TCP socket. The [Socket] exposes | 242 * A high-level class for communicating over a TCP socket. The [Socket] exposes |
228 * both a [Stream] and a [IOSink] interface, making it ideal for | 243 * both a [Stream] and a [IOSink] interface, making it ideal for |
229 * using together with other [Stream]s. | 244 * using together with other [Stream]s. |
230 */ | 245 */ |
231 abstract class Socket implements Stream<List<int>>, IOSink { | 246 abstract class Socket implements Stream<List<int>>, IOSink { |
232 /** | 247 /** |
233 * Creats a new socket connection to the host and port and returns a [Future] | 248 * Creats a new socket connection to the host and port and returns a [Future] |
234 * that will complete with either a [Socket] once connected or an error | 249 * that will complete with either a [Socket] once connected or an error |
235 * if the host-lookup or connection failed. | 250 * if the host-lookup or connection failed. |
Søren Gjesse
2013/04/18 09:07:40
Ditto.
Anders Johnsen
2013/04/18 12:09:45
Done.
| |
236 */ | 251 */ |
237 external static Future<Socket> connect(String host, int port); | 252 external static Future<Socket> connect(host, int port); |
238 | 253 |
239 /** | 254 /** |
240 * Destroy the socket in both directions. Calling [destroy] will make the | 255 * Destroy the socket in both directions. Calling [destroy] will make the |
241 * send a close event on the stream and will no longer react on data being | 256 * send a close event on the stream and will no longer react on data being |
242 * piped to it. | 257 * piped to it. |
243 * | 258 * |
244 * Call [close](inherited from [IOSink]) to only close the [Socket] | 259 * Call [close](inherited from [IOSink]) to only close the [Socket] |
245 * for sending data. | 260 * for sending data. |
246 */ | 261 */ |
247 void destroy(); | 262 void destroy(); |
(...skipping 24 matching lines...) Expand all Loading... | |
272 sb.write(" ($osError)"); | 287 sb.write(" ($osError)"); |
273 } | 288 } |
274 } else if (osError != null) { | 289 } else if (osError != null) { |
275 sb.write(": $osError"); | 290 sb.write(": $osError"); |
276 } | 291 } |
277 return sb.toString(); | 292 return sb.toString(); |
278 } | 293 } |
279 final String message; | 294 final String message; |
280 final OSError osError; | 295 final OSError osError; |
281 } | 296 } |
OLD | NEW |