| 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 int port, | 196 int port, |
| 197 {int backlog: 0, | 197 {int backlog: 0, |
| 198 bool v6Only: false}); | 198 bool v6Only: false}); |
| 199 | 199 |
| 200 /** | 200 /** |
| 201 * Returns the port used by this socket. | 201 * Returns the port used by this socket. |
| 202 */ | 202 */ |
| 203 int get port; | 203 int get port; |
| 204 | 204 |
| 205 /** | 205 /** |
| 206 * Closes the socket. | 206 * Closes the socket. The returned future completes when the socket |
| 207 * is fully closed and is no longer bound. |
| 207 */ | 208 */ |
| 208 void close(); | 209 Future close(); |
| 209 } | 210 } |
| 210 | 211 |
| 211 /** | 212 /** |
| 212 * The [SocketDirection] is used as a parameter to [Socket.close] and | 213 * The [SocketDirection] is used as a parameter to [Socket.close] and |
| 213 * [RawSocket.close] to close a socket in the specified direction(s). | 214 * [RawSocket.close] to close a socket in the specified direction(s). |
| 214 */ | 215 */ |
| 215 class SocketDirection { | 216 class SocketDirection { |
| 216 static const SocketDirection RECEIVE = const SocketDirection._(0); | 217 static const SocketDirection RECEIVE = const SocketDirection._(0); |
| 217 static const SocketDirection SEND = const SocketDirection._(1); | 218 static const SocketDirection SEND = const SocketDirection._(1); |
| 218 static const SocketDirection BOTH = const SocketDirection._(2); | 219 static const SocketDirection BOTH = const SocketDirection._(2); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 239 final _value; | 240 final _value; |
| 240 } | 241 } |
| 241 | 242 |
| 242 /** | 243 /** |
| 243 * Events for the [RawSocket]. | 244 * Events for the [RawSocket]. |
| 244 */ | 245 */ |
| 245 class RawSocketEvent { | 246 class RawSocketEvent { |
| 246 static const RawSocketEvent READ = const RawSocketEvent._(0); | 247 static const RawSocketEvent READ = const RawSocketEvent._(0); |
| 247 static const RawSocketEvent WRITE = const RawSocketEvent._(1); | 248 static const RawSocketEvent WRITE = const RawSocketEvent._(1); |
| 248 static const RawSocketEvent READ_CLOSED = const RawSocketEvent._(2); | 249 static const RawSocketEvent READ_CLOSED = const RawSocketEvent._(2); |
| 250 static const RawSocketEvent CLOSED = const RawSocketEvent._(3); |
| 249 const RawSocketEvent._(this._value); | 251 const RawSocketEvent._(this._value); |
| 250 final int _value; | 252 final int _value; |
| 251 String toString() { | 253 String toString() { |
| 252 return ['RawSocketEvent:READ', | 254 return ['RawSocketEvent:READ', |
| 253 'RawSocketEvent:WRITE', | 255 'RawSocketEvent:WRITE', |
| 254 'RawSocketEvent:READ_CLOSED'][_value]; | 256 'RawSocketEvent:READ_CLOSED', |
| 257 'RawSocketEvent:CLOSED'][_value]; |
| 255 } | 258 } |
| 256 } | 259 } |
| 257 | 260 |
| 258 /** | 261 /** |
| 259 * The [RawSocket] is a low-level interface to a socket, exposing the raw | 262 * The [RawSocket] is a low-level interface to a socket, exposing the raw |
| 260 * events signaled by the system. It's a [Stream] of [RawSocketEvent]s. | 263 * events signaled by the system. It's a [Stream] of [RawSocketEvent]s. |
| 261 */ | 264 */ |
| 262 abstract class RawSocket implements Stream<RawSocketEvent> { | 265 abstract class RawSocket implements Stream<RawSocketEvent> { |
| 263 /** | 266 /** |
| 264 * Creates a new socket connection to the host and port and returns a [Future] | 267 * Creates a new socket connection to the host and port and returns a [Future] |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 sb.write(" ($osError)"); | 424 sb.write(" ($osError)"); |
| 422 } | 425 } |
| 423 } else if (osError != null) { | 426 } else if (osError != null) { |
| 424 sb.write(": $osError"); | 427 sb.write(": $osError"); |
| 425 } | 428 } |
| 426 return sb.toString(); | 429 return sb.toString(); |
| 427 } | 430 } |
| 428 final String message; | 431 final String message; |
| 429 final OSError osError; | 432 final OSError osError; |
| 430 } | 433 } |
| OLD | NEW |