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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 * to true again to receive another write event. | 381 * to true again to receive another write event. |
382 */ | 382 */ |
383 bool writeEventsEnabled; | 383 bool writeEventsEnabled; |
384 | 384 |
385 /** | 385 /** |
386 * Creates a new socket connection to the host and port and returns a [Future] | 386 * Creates a new socket connection to the host and port and returns a [Future] |
387 * that will complete with either a [RawSocket] once connected or an error | 387 * that will complete with either a [RawSocket] once connected or an error |
388 * if the host-lookup or connection failed. | 388 * if the host-lookup or connection failed. |
389 * | 389 * |
390 * [host] can either be a [String] or an [InternetAddress]. If [host] is a | 390 * [host] can either be a [String] or an [InternetAddress]. If [host] is a |
391 * [String], [connect] will perform a [InternetAddress.lookup] and use | 391 * [String], [connect] will perform a [InternetAddress.lookup] and try |
392 * the first value in the list. | 392 * all returned [InternetAddress]es, in turn, until connected. Unless a |
| 393 * connection was established, the error from the first attempt is |
| 394 * returned. |
393 */ | 395 */ |
394 external static Future<RawSocket> connect(host, int port); | 396 external static Future<RawSocket> connect(host, int port); |
395 | 397 |
396 /** | 398 /** |
397 * Returns the number of received and non-read bytes in the socket that | 399 * Returns the number of received and non-read bytes in the socket that |
398 * can be read. | 400 * can be read. |
399 */ | 401 */ |
400 int available(); | 402 int available(); |
401 | 403 |
402 /** | 404 /** |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 * The [Socket] exposes both a [Stream] and a [IOSink] interface, making it | 474 * The [Socket] exposes both a [Stream] and a [IOSink] interface, making it |
473 * ideal for using together with other [Stream]s. | 475 * ideal for using together with other [Stream]s. |
474 */ | 476 */ |
475 abstract class Socket implements Stream<List<int>>, IOSink { | 477 abstract class Socket implements Stream<List<int>>, IOSink { |
476 /** | 478 /** |
477 * Creats a new socket connection to the host and port and returns a [Future] | 479 * Creats a new socket connection to the host and port and returns a [Future] |
478 * that will complete with either a [Socket] once connected or an error | 480 * that will complete with either a [Socket] once connected or an error |
479 * if the host-lookup or connection failed. | 481 * if the host-lookup or connection failed. |
480 * | 482 * |
481 * [host] can either be a [String] or an [InternetAddress]. If [host] is a | 483 * [host] can either be a [String] or an [InternetAddress]. If [host] is a |
482 * [String], [connect] will perform a [InternetAddress.lookup] and use | 484 * [String], [connect] will perform a [InternetAddress.lookup] and try |
483 * the first value in the list. | 485 * all returned [InternetAddress]es, in turn, until connected. Unless a |
| 486 * connection was established, the error from the first attempt is |
| 487 * returned. |
484 */ | 488 */ |
485 external static Future<Socket> connect(host, int port); | 489 external static Future<Socket> connect(host, int port); |
486 | 490 |
487 /** | 491 /** |
488 * Destroy the socket in both directions. Calling [destroy] will make the | 492 * Destroy the socket in both directions. Calling [destroy] will make the |
489 * send a close event on the stream and will no longer react on data being | 493 * send a close event on the stream and will no longer react on data being |
490 * piped to it. | 494 * piped to it. |
491 * | 495 * |
492 * Call [close](inherited from [IOSink]) to only close the [Socket] | 496 * Call [close](inherited from [IOSink]) to only close the [Socket] |
493 * for sending data. | 497 * for sending data. |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 } | 679 } |
676 if (address != null) { | 680 if (address != null) { |
677 sb.write(", address = ${address.host}"); | 681 sb.write(", address = ${address.host}"); |
678 } | 682 } |
679 if (port != null) { | 683 if (port != null) { |
680 sb.write(", port = $port"); | 684 sb.write(", port = $port"); |
681 } | 685 } |
682 return sb.toString(); | 686 return sb.toString(); |
683 } | 687 } |
684 } | 688 } |
OLD | NEW |