| 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 * The RawServerSocket is a server socket, providing a stream of low-level | 8 * The RawServerSocket is a server socket, providing a stream of low-level |
| 9 * [RawSocket]s. | 9 * [RawSocket]s. |
| 10 * | 10 * |
| 11 * See [RawSocket] for more info. | 11 * See [RawSocket] for more info. |
| 12 */ | 12 */ |
| 13 abstract class RawServerSocket implements Stream<RawSocket> { | 13 abstract class RawServerSocket implements Stream<RawSocket> { |
| 14 /** | 14 /** |
| 15 * Returns a future for a [:RawServerSocket:]. When the future | 15 * Returns a future for a [:RawServerSocket:]. When the future |
| 16 * completes the server socket is bound to the given [address] and | 16 * completes the server socket is bound to the given [address] and |
| 17 * [port] and has started listening on it. | 17 * [port] and has started listening on it. |
| 18 * | 18 * |
| 19 * The default value for [address] is 127.0.0.1, which will allow |
| 20 * only incoming connections from the local host. To allow for |
| 21 * incoming connection from the network use either the value 0.0.0.0 |
| 22 * to bind to all interfaces or the IP address of a specific |
| 23 * interface. |
| 24 * |
| 19 * If [port] has the value [:0:] (the default) an ephemeral port will | 25 * If [port] has the value [:0:] (the default) an ephemeral port will |
| 20 * be chosen by the system. The actual port used can be retrieved | 26 * be chosen by the system. The actual port used can be retrieved |
| 21 * using the [:port:] getter. | 27 * using the [:port:] getter. |
| 22 * | 28 * |
| 23 * If [backlog] has the value of [:0:] a reasonable value will be | 29 * The optional argument [backlog] can be used to specify the listen |
| 24 * chosen by the system. | 30 * backlog for the underlying OS listen setup. If [backlog] has the |
| 31 * value of [:0:] (the default) a reasonable value will be chosen by |
| 32 * the system. |
| 25 */ | 33 */ |
| 26 external static Future<RawServerSocket> bind([String address = "127.0.0.1", | 34 external static Future<RawServerSocket> bind([String address = "127.0.0.1", |
| 27 int port = 0, | 35 int port = 0, |
| 28 int backlog = 0]); | 36 int backlog = 0]); |
| 29 | 37 |
| 30 /** | 38 /** |
| 31 * Returns the port used by this socket. | 39 * Returns the port used by this socket. |
| 32 */ | 40 */ |
| 33 int get port; | 41 int get port; |
| 34 | 42 |
| 35 /** | 43 /** |
| 36 * Closes the socket. | 44 * Closes the socket. |
| 37 */ | 45 */ |
| 38 void close(); | 46 void close(); |
| 39 } | 47 } |
| 40 | 48 |
| 41 | 49 |
| 42 /** | 50 /** |
| 43 * The [ServerSocket] is server socket, providing a stream of high-level | 51 * The [ServerSocket] is server socket, providing a stream of high-level |
| 44 * [Socket]s. | 52 * [Socket]s. |
| 45 * | 53 * |
| 46 * See [Socket] for more info. | 54 * See [Socket] for more info. |
| 47 */ | 55 */ |
| 48 abstract class ServerSocket implements Stream<Socket> { | 56 abstract class ServerSocket implements Stream<Socket> { |
| 49 /** | 57 /** |
| 50 * Returns a future for a [:ServerSocket:]. When the future | 58 * Returns a future for a [:ServerSocket:]. When the future |
| 51 * completes the server socket is bound to the given [address] and | 59 * completes the server socket is bound to the given [address] and |
| 52 * [port] and has started listening on it. | 60 * [port] and has started listening on it. |
| 53 * | 61 * |
| 62 * The default value for [address] is 127.0.0.1, which will allow |
| 63 * only incoming connections from the local host. To allow for |
| 64 * incoming connection from the network use either the value 0.0.0.0 |
| 65 * to bind to all interfaces or the IP address of a specific |
| 66 * interface. |
| 67 * |
| 54 * If [port] has the value [:0:] (the default) an ephemeral port will | 68 * If [port] has the value [:0:] (the default) an ephemeral port will |
| 55 * be chosen by the system. The actual port used can be retrieved | 69 * be chosen by the system. The actual port used can be retrieved |
| 56 * using the [port] getter. | 70 * using the [port] getter. |
| 57 * | 71 * |
| 58 * If [backlog] has the value of [:0:] a reasonable value will be | 72 * The optional argument [backlog] can be used to specify the listen |
| 59 * chosen by the system. | 73 * backlog for the underlying OS listen setup. If [backlog] has the |
| 74 * value of [:0:] (the default) a reasonable value will be chosen by |
| 75 * the system. |
| 60 */ | 76 */ |
| 61 external static Future<ServerSocket> bind([String address = "127.0.0.1", | 77 external static Future<ServerSocket> bind([String address = "127.0.0.1", |
| 62 int port = 0, | 78 int port = 0, |
| 63 int backlog = 0]); | 79 int backlog = 0]); |
| 64 | 80 |
| 65 /** | 81 /** |
| 66 * Returns the port used by this socket. | 82 * Returns the port used by this socket. |
| 67 */ | 83 */ |
| 68 int get port; | 84 int get port; |
| 69 | 85 |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 sb.write(" ($osError)"); | 272 sb.write(" ($osError)"); |
| 257 } | 273 } |
| 258 } else if (osError != null) { | 274 } else if (osError != null) { |
| 259 sb.write(": $osError"); | 275 sb.write(": $osError"); |
| 260 } | 276 } |
| 261 return sb.toString(); | 277 return sb.toString(); |
| 262 } | 278 } |
| 263 final String message; | 279 final String message; |
| 264 final OSError osError; | 280 final OSError osError; |
| 265 } | 281 } |
| OLD | NEW |