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

Side by Side Diff: runtime/bin/socket_patch.dart

Issue 2205913003: Better error-message when bind fails. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Add android support. Created 4 years, 4 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
« no previous file with comments | « runtime/bin/socket_macos.cc ('k') | runtime/bin/socket_unsupported.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 patch class RawServerSocket { 5 patch class RawServerSocket {
6 /* patch */ static Future<RawServerSocket> bind(address, 6 /* patch */ static Future<RawServerSocket> bind(address,
7 int port, 7 int port,
8 {int backlog: 0, 8 {int backlog: 0,
9 bool v6Only: false, 9 bool v6Only: false,
10 bool shared: false}) { 10 bool shared: false}) {
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 if (sourceAddress == null) { 424 if (sourceAddress == null) {
425 result = socket.nativeCreateConnect(address._in_addr, port); 425 result = socket.nativeCreateConnect(address._in_addr, port);
426 } else { 426 } else {
427 assert(sourceAddress is _InternetAddress); 427 assert(sourceAddress is _InternetAddress);
428 result = socket.nativeCreateBindConnect( 428 result = socket.nativeCreateBindConnect(
429 address._in_addr, port, sourceAddress._in_addr); 429 address._in_addr, port, sourceAddress._in_addr);
430 } 430 }
431 if (result is OSError) { 431 if (result is OSError) {
432 // Keep first error, if present. 432 // Keep first error, if present.
433 if (error == null) { 433 if (error == null) {
434 error = createError(result, "Connection failed", address, port); 434 int errorCode = result.errorCode;
435 if (errorCode != null && socket.isBindError(errorCode)) {
436 error = createError(result, "Bind failed", sourceAddress);
437 } else {
438 error =
439 createError(result, "Connection failed", address, port);
440 }
435 } 441 }
436 connectNext(); 442 connectNext();
437 } else { 443 } else {
438 // Query the local port, for error messages. 444 // Query the local port, for error messages.
439 socket.port; 445 socket.port;
440 // Set up timer for when we should retry the next address 446 // Set up timer for when we should retry the next address
441 // (if any). 447 // (if any).
442 var duration = address.isLoopback ? 448 var duration = address.isLoopback ?
443 _RETRY_DURATION_LOOPBACK : 449 _RETRY_DURATION_LOOPBACK :
444 _RETRY_DURATION; 450 _RETRY_DURATION;
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 nativeWrite(List<int> buffer, int offset, int bytes) 1074 nativeWrite(List<int> buffer, int offset, int bytes)
1069 native "Socket_WriteList"; 1075 native "Socket_WriteList";
1070 nativeSendTo(List<int> buffer, int offset, int bytes, 1076 nativeSendTo(List<int> buffer, int offset, int bytes,
1071 List<int> address, int port) 1077 List<int> address, int port)
1072 native "Socket_SendTo"; 1078 native "Socket_SendTo";
1073 nativeCreateConnect(List<int> addr, 1079 nativeCreateConnect(List<int> addr,
1074 int port) native "Socket_CreateConnect"; 1080 int port) native "Socket_CreateConnect";
1075 nativeCreateBindConnect( 1081 nativeCreateBindConnect(
1076 List<int> addr, int port, List<int> sourceAddr) 1082 List<int> addr, int port, List<int> sourceAddr)
1077 native "Socket_CreateBindConnect"; 1083 native "Socket_CreateBindConnect";
1084 bool isBindError(int errorNumber) native "Socket_IsBindError";
1078 nativeCreateBindListen(List<int> addr, int port, int backlog, bool v6Only, 1085 nativeCreateBindListen(List<int> addr, int port, int backlog, bool v6Only,
1079 bool shared) 1086 bool shared)
1080 native "ServerSocket_CreateBindListen"; 1087 native "ServerSocket_CreateBindListen";
1081 nativeCreateBindDatagram(List<int> addr, int port, bool reuseAddress) 1088 nativeCreateBindDatagram(List<int> addr, int port, bool reuseAddress)
1082 native "Socket_CreateBindDatagram"; 1089 native "Socket_CreateBindDatagram";
1083 nativeAccept(_NativeSocket socket) native "ServerSocket_Accept"; 1090 nativeAccept(_NativeSocket socket) native "ServerSocket_Accept";
1084 int nativeGetPort() native "Socket_GetPort"; 1091 int nativeGetPort() native "Socket_GetPort";
1085 List nativeGetRemotePeer() native "Socket_GetRemotePeer"; 1092 List nativeGetRemotePeer() native "Socket_GetRemotePeer";
1086 int nativeGetSocketId() native "Socket_GetSocketId"; 1093 int nativeGetSocketId() native "Socket_GetSocketId";
1087 OSError nativeGetError() native "Socket_GetError"; 1094 OSError nativeGetError() native "Socket_GetError";
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
1857 Datagram _makeDatagram(List<int> data, 1864 Datagram _makeDatagram(List<int> data,
1858 String address, 1865 String address,
1859 List<int> in_addr, 1866 List<int> in_addr,
1860 int port) { 1867 int port) {
1861 return new Datagram( 1868 return new Datagram(
1862 data, 1869 data,
1863 new _InternetAddress(address, null, in_addr), 1870 new _InternetAddress(address, null, in_addr),
1864 port); 1871 port);
1865 } 1872 }
1866 1873
OLDNEW
« no previous file with comments | « runtime/bin/socket_macos.cc ('k') | runtime/bin/socket_unsupported.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698