Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: sdk/lib/io/socket.dart

Issue 908873002: Add support to specify the source address for socket connect (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added dart2js patch file Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 */ 115 */
116 bool get isMulticast; 116 bool get isMulticast;
117 117
118 /** 118 /**
119 * Creates a new [InternetAddress] from a numeric address. 119 * Creates a new [InternetAddress] from a numeric address.
120 * 120 *
121 * If the address in [address] is not a numeric IPv4 121 * If the address in [address] is not a numeric IPv4
122 * (dotted-decimal notation) or IPv6 (hexadecimal representation). 122 * (dotted-decimal notation) or IPv6 (hexadecimal representation).
123 * address [ArgumentError] is thrown. 123 * address [ArgumentError] is thrown.
124 */ 124 */
125 external factory InternetAddress(String address); 125 external factory InternetAddress(String address);
kustermann 2015/02/10 15:15:37 See here.
126 126
127 /** 127 /**
128 * Perform a reverse dns lookup on the [address], creating a new 128 * Perform a reverse dns lookup on the [address], creating a new
129 * [InternetAddress] where the host field set to the result. 129 * [InternetAddress] where the host field set to the result.
130 */ 130 */
131 Future<InternetAddress> reverse(); 131 Future<InternetAddress> reverse();
132 132
133 /** 133 /**
134 * Lookup a host, returning a Future of a list of 134 * Lookup a host, returning a Future of a list of
135 * [InternetAddress]s. If [type] is [InternetAddressType.ANY], it 135 * [InternetAddress]s. If [type] is [InternetAddressType.ANY], it
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, until connected. Unless a 453 * all returned [InternetAddress]es, until connected. Unless a
454 * connection was established, the error from the first failing connection is 454 * connection was established, the error from the first failing connection is
455 * returned. 455 * returned.
456 *
457 * The argument [sourceAddress] can be used to specify the local
458 * address to bind when making the connection. `sourceAddress` can either
459 * be a `String` or an `InternetAddress`. If a `String` is passed it must
460 * hold a numeric IP address.
456 */ 461 */
457 external static Future<RawSocket> connect(host, int port); 462 external static Future<RawSocket> connect(host, int port, {sourceAddress});
kevmoo 2015/02/10 15:07:08 What's the expected format of `sourceAddress` if n
kustermann 2015/02/10 15:15:37 Because it's much more convenient to write. It's a
Søren Gjesse 2015/02/11 10:12:22 I thought about this, and with the first argument
458 463
459 /** 464 /**
460 * Returns the number of received and non-read bytes in the socket that 465 * Returns the number of received and non-read bytes in the socket that
461 * can be read. 466 * can be read.
462 */ 467 */
463 int available(); 468 int available();
464 469
465 /** 470 /**
466 * Read up to [len] bytes from the socket. This function is 471 * Read up to [len] bytes from the socket. This function is
467 * non-blocking and will only return data if data is available. The 472 * non-blocking and will only return data if data is available. The
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 /** 544 /**
540 * Creates a new socket connection to the host and port and returns a [Future] 545 * 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 546 * that will complete with either a [Socket] once connected or an error
542 * if the host-lookup or connection failed. 547 * if the host-lookup or connection failed.
543 * 548 *
544 * [host] can either be a [String] or an [InternetAddress]. If [host] is a 549 * [host] can either be a [String] or an [InternetAddress]. If [host] is a
545 * [String], [connect] will perform a [InternetAddress.lookup] and try 550 * [String], [connect] will perform a [InternetAddress.lookup] and try
546 * all returned [InternetAddress]es, until connected. Unless a 551 * all returned [InternetAddress]es, until connected. Unless a
547 * connection was established, the error from the first failing connection is 552 * connection was established, the error from the first failing connection is
548 * returned. 553 * returned.
554 *
555 * The argument [sourceAddress] can be used to specify the local
556 * address to bind when making the connection. `sourceAddress` can either
557 * be a `String` or an `InternetAddress`. If a `String` is passed it must
558 * hold a numeric IP address.
549 */ 559 */
550 external static Future<Socket> connect(host, int port); 560 external static Future<Socket> connect(host, int port, {sourceAddress});
551 561
552 /** 562 /**
553 * Destroy the socket in both directions. Calling [destroy] will make the 563 * 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 564 * send a close event on the stream and will no longer react on data being
555 * piped to it. 565 * piped to it.
556 * 566 *
557 * Call [close](inherited from [IOSink]) to only close the [Socket] 567 * Call [close](inherited from [IOSink]) to only close the [Socket]
558 * for sending data. 568 * for sending data.
559 */ 569 */
560 void destroy(); 570 void destroy();
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 } 750 }
741 if (address != null) { 751 if (address != null) {
742 sb.write(", address = ${address.host}"); 752 sb.write(", address = ${address.host}");
743 } 753 }
744 if (port != null) { 754 if (port != null) {
745 sb.write(", port = $port"); 755 sb.write(", port = $port");
746 } 756 }
747 return sb.toString(); 757 return sb.toString();
748 } 758 }
749 } 759 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/js_lib/io_patch.dart ('k') | tests/standalone/io/socket_source_address_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698