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 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 Loading... |
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 int errorCode = result.errorCode; | 434 error = createError(result, "Connection failed", address, port); |
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 } | |
441 } | 435 } |
442 connectNext(); | 436 connectNext(); |
443 } else { | 437 } else { |
444 // Query the local port, for error messages. | 438 // Query the local port, for error messages. |
445 socket.port; | 439 socket.port; |
446 // Set up timer for when we should retry the next address | 440 // Set up timer for when we should retry the next address |
447 // (if any). | 441 // (if any). |
448 var duration = address.isLoopback ? | 442 var duration = address.isLoopback ? |
449 _RETRY_DURATION_LOOPBACK : | 443 _RETRY_DURATION_LOOPBACK : |
450 _RETRY_DURATION; | 444 _RETRY_DURATION; |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1074 nativeWrite(List<int> buffer, int offset, int bytes) | 1068 nativeWrite(List<int> buffer, int offset, int bytes) |
1075 native "Socket_WriteList"; | 1069 native "Socket_WriteList"; |
1076 nativeSendTo(List<int> buffer, int offset, int bytes, | 1070 nativeSendTo(List<int> buffer, int offset, int bytes, |
1077 List<int> address, int port) | 1071 List<int> address, int port) |
1078 native "Socket_SendTo"; | 1072 native "Socket_SendTo"; |
1079 nativeCreateConnect(List<int> addr, | 1073 nativeCreateConnect(List<int> addr, |
1080 int port) native "Socket_CreateConnect"; | 1074 int port) native "Socket_CreateConnect"; |
1081 nativeCreateBindConnect( | 1075 nativeCreateBindConnect( |
1082 List<int> addr, int port, List<int> sourceAddr) | 1076 List<int> addr, int port, List<int> sourceAddr) |
1083 native "Socket_CreateBindConnect"; | 1077 native "Socket_CreateBindConnect"; |
1084 bool isBindError(int errorNumber) native "Socket_IsBindError"; | |
1085 nativeCreateBindListen(List<int> addr, int port, int backlog, bool v6Only, | 1078 nativeCreateBindListen(List<int> addr, int port, int backlog, bool v6Only, |
1086 bool shared) | 1079 bool shared) |
1087 native "ServerSocket_CreateBindListen"; | 1080 native "ServerSocket_CreateBindListen"; |
1088 nativeCreateBindDatagram(List<int> addr, int port, bool reuseAddress) | 1081 nativeCreateBindDatagram(List<int> addr, int port, bool reuseAddress) |
1089 native "Socket_CreateBindDatagram"; | 1082 native "Socket_CreateBindDatagram"; |
1090 nativeAccept(_NativeSocket socket) native "ServerSocket_Accept"; | 1083 nativeAccept(_NativeSocket socket) native "ServerSocket_Accept"; |
1091 int nativeGetPort() native "Socket_GetPort"; | 1084 int nativeGetPort() native "Socket_GetPort"; |
1092 List nativeGetRemotePeer() native "Socket_GetRemotePeer"; | 1085 List nativeGetRemotePeer() native "Socket_GetRemotePeer"; |
1093 int nativeGetSocketId() native "Socket_GetSocketId"; | 1086 int nativeGetSocketId() native "Socket_GetSocketId"; |
1094 OSError nativeGetError() native "Socket_GetError"; | 1087 OSError nativeGetError() native "Socket_GetError"; |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1864 Datagram _makeDatagram(List<int> data, | 1857 Datagram _makeDatagram(List<int> data, |
1865 String address, | 1858 String address, |
1866 List<int> in_addr, | 1859 List<int> in_addr, |
1867 int port) { | 1860 int port) { |
1868 return new Datagram( | 1861 return new Datagram( |
1869 data, | 1862 data, |
1870 new _InternetAddress(address, null, in_addr), | 1863 new _InternetAddress(address, null, in_addr), |
1871 port); | 1864 port); |
1872 } | 1865 } |
1873 | 1866 |
OLD | NEW |