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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 */ | 443 */ |
444 bool writeEventsEnabled; | 444 bool writeEventsEnabled; |
445 | 445 |
446 /** | 446 /** |
447 * Creates a new socket connection to the host and port and returns a [Future] | 447 * Creates a new socket connection to the host and port and returns a [Future] |
448 * that will complete with either a [RawSocket] once connected or an error | 448 * that will complete with either a [RawSocket] once connected or an error |
449 * if the host-lookup or connection failed. | 449 * if the host-lookup or connection failed. |
450 * | 450 * |
451 * [host] can either be a [String] or an [InternetAddress]. If [host] is a | 451 * [host] can either be a [String] or an [InternetAddress]. If [host] is a |
452 * [String], [connect] will perform a [InternetAddress.lookup] and try | 452 * [String], [connect] will perform a [InternetAddress.lookup] and try |
453 * all returned [InternetAddress]es, in turn, until connected. Unless a | 453 * all returned [InternetAddress]es, until connected. Unless a |
454 * connection was established, the error from the first attempt is | 454 * connection was established, the error from the first failing connection is |
455 * returned. | 455 * returned. |
456 */ | 456 */ |
457 external static Future<RawSocket> connect(host, int port); | 457 external static Future<RawSocket> connect(host, int port); |
458 | 458 |
459 /** | 459 /** |
460 * Returns the number of received and non-read bytes in the socket that | 460 * Returns the number of received and non-read bytes in the socket that |
461 * can be read. | 461 * can be read. |
462 */ | 462 */ |
463 int available(); | 463 int available(); |
464 | 464 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 * ideal for using together with other [Stream]s. | 536 * ideal for using together with other [Stream]s. |
537 */ | 537 */ |
538 abstract class Socket implements Stream<List<int>>, IOSink { | 538 abstract class Socket implements Stream<List<int>>, IOSink { |
539 /** | 539 /** |
540 * Creates a new socket connection to the host and port and returns a [Future] | 540 * Creates a new socket connection to the host and port and returns a [Future] |
541 * that will complete with either a [Socket] once connected or an error | 541 * that will complete with either a [Socket] once connected or an error |
542 * if the host-lookup or connection failed. | 542 * if the host-lookup or connection failed. |
543 * | 543 * |
544 * [host] can either be a [String] or an [InternetAddress]. If [host] is a | 544 * [host] can either be a [String] or an [InternetAddress]. If [host] is a |
545 * [String], [connect] will perform a [InternetAddress.lookup] and try | 545 * [String], [connect] will perform a [InternetAddress.lookup] and try |
546 * all returned [InternetAddress]es, in turn, until connected. Unless a | 546 * all returned [InternetAddress]es, until connected. Unless a |
547 * connection was established, the error from the first attempt is | 547 * connection was established, the error from the first failing connection is |
548 * returned. | 548 * returned. |
549 */ | 549 */ |
550 external static Future<Socket> connect(host, int port); | 550 external static Future<Socket> connect(host, int port); |
551 | 551 |
552 /** | 552 /** |
553 * Destroy the socket in both directions. Calling [destroy] will make the | 553 * Destroy the socket in both directions. Calling [destroy] will make the |
554 * send a close event on the stream and will no longer react on data being | 554 * send a close event on the stream and will no longer react on data being |
555 * piped to it. | 555 * piped to it. |
556 * | 556 * |
557 * Call [close](inherited from [IOSink]) to only close the [Socket] | 557 * Call [close](inherited from [IOSink]) to only close the [Socket] |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 } | 740 } |
741 if (address != null) { | 741 if (address != null) { |
742 sb.write(", address = ${address.host}"); | 742 sb.write(", address = ${address.host}"); |
743 } | 743 } |
744 if (port != null) { | 744 if (port != null) { |
745 sb.write(", port = $port"); | 745 sb.write(", port = $port"); |
746 } | 746 } |
747 return sb.toString(); | 747 return sb.toString(); |
748 } | 748 } |
749 } | 749 } |
OLD | NEW |