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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 * Returns the remote port connected to by this socket. | 374 * Returns the remote port connected to by this socket. |
375 */ | 375 */ |
376 int get remotePort; | 376 int get remotePort; |
377 | 377 |
378 /** | 378 /** |
379 * Returns the [InternetAddress] used to connect this socket. | 379 * Returns the [InternetAddress] used to connect this socket. |
380 */ | 380 */ |
381 InternetAddress get address; | 381 InternetAddress get address; |
382 | 382 |
383 /** | 383 /** |
384 * Returns the remote host connected to by this socket. | 384 * Returns the remote [InternetAddress] connected to by this socket. |
385 */ | 385 */ |
386 String get remoteHost; | 386 InternetAddress get remoteAddress; |
387 | 387 |
388 /** | 388 /** |
389 * Closes the socket. Returns a Future that completes with [this] when the | 389 * Closes the socket. Returns a Future that completes with [this] when the |
390 * underlying connection is completely destroyed. | 390 * underlying connection is completely destroyed. |
391 * | 391 * |
392 * Calling [close] will never throw an exception | 392 * Calling [close] will never throw an exception |
393 * and calling it several times is supported. Calling [close] can result in | 393 * and calling it several times is supported. Calling [close] can result in |
394 * a [RawSocketEvent.READ_CLOSED] event. | 394 * a [RawSocketEvent.READ_CLOSED] event. |
395 */ | 395 */ |
396 Future<RawSocket> close(); | 396 Future<RawSocket> close(); |
(...skipping 23 matching lines...) Expand all Loading... |
420 /** | 420 /** |
421 * Use [setOption] to customize the [RawSocket]. See [SocketOption] for | 421 * Use [setOption] to customize the [RawSocket]. See [SocketOption] for |
422 * available options. | 422 * available options. |
423 * | 423 * |
424 * Returns [true] if the option was set successfully, false otherwise. | 424 * Returns [true] if the option was set successfully, false otherwise. |
425 */ | 425 */ |
426 bool setOption(SocketOption option, bool enabled); | 426 bool setOption(SocketOption option, bool enabled); |
427 } | 427 } |
428 | 428 |
429 /** | 429 /** |
430 * A high-level class for communicating over a TCP socket. | 430 * A high-level class for communicating over a TCP socket. |
431 * | 431 * |
432 * The [Socket] exposes both a [Stream] and a [IOSink] interface, making it | 432 * The [Socket] exposes both a [Stream] and a [IOSink] interface, making it |
433 * ideal for using together with other [Stream]s. | 433 * ideal for using together with other [Stream]s. |
434 */ | 434 */ |
435 abstract class Socket implements Stream<List<int>>, IOSink { | 435 abstract class Socket implements Stream<List<int>>, IOSink { |
436 /** | 436 /** |
437 * Creats a new socket connection to the host and port and returns a [Future] | 437 * Creats a new socket connection to the host and port and returns a [Future] |
438 * that will complete with either a [Socket] once connected or an error | 438 * that will complete with either a [Socket] once connected or an error |
439 * if the host-lookup or connection failed. | 439 * if the host-lookup or connection failed. |
440 * | 440 * |
441 * [host] can either be a [String] or an [InternetAddress]. If [host] is a | 441 * [host] can either be a [String] or an [InternetAddress]. If [host] is a |
442 * [String], [connect] will perform a [InternetAddress.lookup] and use | 442 * [String], [connect] will perform a [InternetAddress.lookup] and use |
(...skipping 28 matching lines...) Expand all Loading... |
471 * Returns the remote port connected to by this socket. | 471 * Returns the remote port connected to by this socket. |
472 */ | 472 */ |
473 int get remotePort; | 473 int get remotePort; |
474 | 474 |
475 /** | 475 /** |
476 * Returns the [InternetAddress] used to connect this socket. | 476 * Returns the [InternetAddress] used to connect this socket. |
477 */ | 477 */ |
478 InternetAddress get address; | 478 InternetAddress get address; |
479 | 479 |
480 /** | 480 /** |
481 * Returns the remote host connected to by this socket. | 481 * Returns the remote [InternetAddress] connected to by this socket. |
482 */ | 482 */ |
483 String get remoteHost; | 483 InternetAddress get remoteAddress; |
484 } | 484 } |
485 | 485 |
486 | 486 |
487 class SocketException implements IOException { | 487 class SocketException implements IOException { |
488 final String message; | 488 final String message; |
489 final OSError osError; | 489 final OSError osError; |
490 final InternetAddress address; | 490 final InternetAddress address; |
491 final int port; | 491 final int port; |
492 | 492 |
493 const SocketException(String this.message, | 493 const SocketException(String this.message, |
(...skipping 18 matching lines...) Expand all Loading... |
512 } else { | 512 } else { |
513 sb.write(", address = ${address.address}"); | 513 sb.write(", address = ${address.address}"); |
514 } | 514 } |
515 } | 515 } |
516 if (port != null) { | 516 if (port != null) { |
517 sb.write(", port = $port"); | 517 sb.write(", port = $port"); |
518 } | 518 } |
519 return sb.toString(); | 519 return sb.toString(); |
520 } | 520 } |
521 } | 521 } |
OLD | NEW |