| 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 int port, | 195 int port, |
| 196 {int backlog: 0, | 196 {int backlog: 0, |
| 197 bool v6Only: false}); | 197 bool v6Only: false}); |
| 198 | 198 |
| 199 /** | 199 /** |
| 200 * Returns the port used by this socket. | 200 * Returns the port used by this socket. |
| 201 */ | 201 */ |
| 202 int get port; | 202 int get port; |
| 203 | 203 |
| 204 /** | 204 /** |
| 205 * Closes the socket. | 205 * Closes the socket. The returned future completes when the socket |
| 206 * is fully closed and is no longer bound. |
| 206 */ | 207 */ |
| 207 void close(); | 208 Future<RawServerSocket> close(); |
| 208 } | 209 } |
| 209 | 210 |
| 210 | 211 |
| 211 /** | 212 /** |
| 212 * A [ServerSocket] represents a listening socket, and provides a | 213 * A [ServerSocket] represents a listening socket, and provides a |
| 213 * stream of [Socket] objects, one for each connection made to the | 214 * stream of [Socket] objects, one for each connection made to the |
| 214 * listening socket. | 215 * listening socket. |
| 215 * | 216 * |
| 216 * See [Socket] for more info. | 217 * See [Socket] for more info. |
| 217 */ | 218 */ |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 | 254 |
| 254 /** | 255 /** |
| 255 * Returns the port used by this socket. | 256 * Returns the port used by this socket. |
| 256 */ | 257 */ |
| 257 int get port; | 258 int get port; |
| 258 | 259 |
| 259 /** | 260 /** |
| 260 * Closes the socket. The returned future completes when the socket | 261 * Closes the socket. The returned future completes when the socket |
| 261 * is fully closed and is no longer bound. | 262 * is fully closed and is no longer bound. |
| 262 */ | 263 */ |
| 263 Future close(); | 264 Future<ServerSocket> close(); |
| 264 } | 265 } |
| 265 | 266 |
| 266 /** | 267 /** |
| 267 * The [SocketDirection] is used as a parameter to [Socket.close] and | 268 * The [SocketDirection] is used as a parameter to [Socket.close] and |
| 268 * [RawSocket.close] to close a socket in the specified direction(s). | 269 * [RawSocket.close] to close a socket in the specified direction(s). |
| 269 */ | 270 */ |
| 270 class SocketDirection { | 271 class SocketDirection { |
| 271 static const SocketDirection RECEIVE = const SocketDirection._(0); | 272 static const SocketDirection RECEIVE = const SocketDirection._(0); |
| 272 static const SocketDirection SEND = const SocketDirection._(1); | 273 static const SocketDirection SEND = const SocketDirection._(1); |
| 273 static const SocketDirection BOTH = const SocketDirection._(2); | 274 static const SocketDirection BOTH = const SocketDirection._(2); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 * Returns the [InternetAddress] used to connect this socket. | 369 * Returns the [InternetAddress] used to connect this socket. |
| 369 */ | 370 */ |
| 370 InternetAddress get address; | 371 InternetAddress get address; |
| 371 | 372 |
| 372 /** | 373 /** |
| 373 * Returns the remote host connected to by this socket. | 374 * Returns the remote host connected to by this socket. |
| 374 */ | 375 */ |
| 375 String get remoteHost; | 376 String get remoteHost; |
| 376 | 377 |
| 377 /** | 378 /** |
| 378 * Closes the socket. Calling [close] will never throw an exception | 379 * Closes the socket. Returns a Future that completes with [this] when the |
| 380 * underlying connection is completely destroyed. |
| 381 * |
| 382 * Calling [close] will never throw an exception |
| 379 * and calling it several times is supported. Calling [close] can result in | 383 * and calling it several times is supported. Calling [close] can result in |
| 380 * a [RawSocketEvent.READ_CLOSED] event. | 384 * a [RawSocketEvent.READ_CLOSED] event. |
| 381 */ | 385 */ |
| 382 void close(); | 386 Future<RawSocket> close(); |
| 383 | 387 |
| 384 /** | 388 /** |
| 385 * Shutdown the socket in the [direction]. Calling [shutdown] will never | 389 * Shutdown the socket in the [direction]. Calling [shutdown] will never |
| 386 * throw an exception and calling it several times is supported. Calling | 390 * throw an exception and calling it several times is supported. Calling |
| 387 * shutdown with either [SocketDirection.BOTH] or [SocketDirection.RECEIVE] | 391 * shutdown with either [SocketDirection.BOTH] or [SocketDirection.RECEIVE] |
| 388 * can result in a [RawSocketEvent.READ_CLOSED] event. | 392 * can result in a [RawSocketEvent.READ_CLOSED] event. |
| 389 */ | 393 */ |
| 390 void shutdown(SocketDirection direction); | 394 void shutdown(SocketDirection direction); |
| 391 | 395 |
| 392 /** | 396 /** |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 } else { | 501 } else { |
| 498 sb.write(", address = ${address.address}"); | 502 sb.write(", address = ${address.address}"); |
| 499 } | 503 } |
| 500 } | 504 } |
| 501 if (port != null) { | 505 if (port != null) { |
| 502 sb.write(", port = $port"); | 506 sb.write(", port = $port"); |
| 503 } | 507 } |
| 504 return sb.toString(); | 508 return sb.toString(); |
| 505 } | 509 } |
| 506 } | 510 } |
| OLD | NEW |