| 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 * [InternetAddressType] is the type an [InternetAddress]. Currently, | 8 * [InternetAddressType] is the type an [InternetAddress]. Currently, |
| 9 * IP version 4 (IPv4) and IP version 6 (IPv6) are supported. | 9 * IP version 4 (IPv4) and IP version 6 (IPv6) are supported. |
| 10 */ | 10 */ |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 * [host] can either be a [String] or an [InternetAddress]. If [host] is a | 417 * [host] can either be a [String] or an [InternetAddress]. If [host] is a |
| 418 * [String], [connect] will perform a [InternetAddress.lookup] and try | 418 * [String], [connect] will perform a [InternetAddress.lookup] and try |
| 419 * all returned [InternetAddress]es, until connected. Unless a | 419 * all returned [InternetAddress]es, until connected. Unless a |
| 420 * connection was established, the error from the first failing connection is | 420 * connection was established, the error from the first failing connection is |
| 421 * returned. | 421 * returned. |
| 422 * | 422 * |
| 423 * The argument [sourceAddress] can be used to specify the local | 423 * The argument [sourceAddress] can be used to specify the local |
| 424 * address to bind when making the connection. `sourceAddress` can either | 424 * address to bind when making the connection. `sourceAddress` can either |
| 425 * be a `String` or an `InternetAddress`. If a `String` is passed it must | 425 * be a `String` or an `InternetAddress`. If a `String` is passed it must |
| 426 * hold a numeric IP address. | 426 * hold a numeric IP address. |
| 427 * |
| 428 * The argument [timeout] is used to specify the maximum allowed time to wait |
| 429 * for a connection to be established. If [timeout] is longer than the system |
| 430 * level timeout duration, a timeout may occur sooner than specified in |
| 431 * [timeout]. On timeout, a [SocketException] is thrown and all ongoing |
| 432 * connection attempts to [host] are cancelled. |
| 427 */ | 433 */ |
| 428 external static Future<RawSocket> connect(host, int port, {sourceAddress}); | 434 external static Future<RawSocket> connect(host, int port, |
| 435 {sourceAddress, Duration timeout}); |
| 429 | 436 |
| 430 /** | 437 /** |
| 431 * Returns the number of received and non-read bytes in the socket that | 438 * Returns the number of received and non-read bytes in the socket that |
| 432 * can be read. | 439 * can be read. |
| 433 */ | 440 */ |
| 434 int available(); | 441 int available(); |
| 435 | 442 |
| 436 /** | 443 /** |
| 437 * Read up to [len] bytes from the socket. This function is | 444 * Read up to [len] bytes from the socket. This function is |
| 438 * non-blocking and will only return data if data is available. The | 445 * non-blocking and will only return data if data is available. The |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 * [host] can either be a [String] or an [InternetAddress]. If [host] is a | 522 * [host] can either be a [String] or an [InternetAddress]. If [host] is a |
| 516 * [String], [connect] will perform a [InternetAddress.lookup] and try | 523 * [String], [connect] will perform a [InternetAddress.lookup] and try |
| 517 * all returned [InternetAddress]es, until connected. Unless a | 524 * all returned [InternetAddress]es, until connected. Unless a |
| 518 * connection was established, the error from the first failing connection is | 525 * connection was established, the error from the first failing connection is |
| 519 * returned. | 526 * returned. |
| 520 * | 527 * |
| 521 * The argument [sourceAddress] can be used to specify the local | 528 * The argument [sourceAddress] can be used to specify the local |
| 522 * address to bind when making the connection. `sourceAddress` can either | 529 * address to bind when making the connection. `sourceAddress` can either |
| 523 * be a `String` or an `InternetAddress`. If a `String` is passed it must | 530 * be a `String` or an `InternetAddress`. If a `String` is passed it must |
| 524 * hold a numeric IP address. | 531 * hold a numeric IP address. |
| 532 * |
| 533 * The argument [timeout] is used to specify the maximum allowed time to wait |
| 534 * for a connection to be established. If [timeout] is longer than the system |
| 535 * level timeout duration, a timeout may occur sooner than specified in |
| 536 * [timeout]. On timeout, a [SocketException] is thrown and all ongoing |
| 537 * connection attempts to [host] are cancelled. |
| 525 */ | 538 */ |
| 526 external static Future<Socket> connect(host, int port, {sourceAddress}); | 539 external static Future<Socket> connect(host, int port, |
| 540 {sourceAddress, Duration timeout}); |
| 527 | 541 |
| 528 /** | 542 /** |
| 529 * Destroy the socket in both directions. Calling [destroy] will make the | 543 * Destroy the socket in both directions. Calling [destroy] will make the |
| 530 * send a close event on the stream and will no longer react on data being | 544 * send a close event on the stream and will no longer react on data being |
| 531 * piped to it. | 545 * piped to it. |
| 532 * | 546 * |
| 533 * Call [close](inherited from [IOSink]) to only close the [Socket] | 547 * Call [close](inherited from [IOSink]) to only close the [Socket] |
| 534 * for sending data. | 548 * for sending data. |
| 535 */ | 549 */ |
| 536 void destroy(); | 550 void destroy(); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 } | 738 } |
| 725 if (address != null) { | 739 if (address != null) { |
| 726 sb.write(", address = ${address.host}"); | 740 sb.write(", address = ${address.host}"); |
| 727 } | 741 } |
| 728 if (port != null) { | 742 if (port != null) { |
| 729 sb.write(", port = $port"); | 743 sb.write(", port = $port"); |
| 730 } | 744 } |
| 731 return sb.toString(); | 745 return sb.toString(); |
| 732 } | 746 } |
| 733 } | 747 } |
| OLD | NEW |