| 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 return _RawServerSocket.bind(address, port, backlog, v6Only); | 10 return _RawServerSocket.bind(address, port, backlog, v6Only); |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 }) | 296 }) |
| 297 .then((address) { | 297 .then((address) { |
| 298 ensureSocketService(); | 298 ensureSocketService(); |
| 299 var socket = new _NativeSocket.normal(); | 299 var socket = new _NativeSocket.normal(); |
| 300 socket.address = address; | 300 socket.address = address; |
| 301 var result = socket.nativeCreateConnect( | 301 var result = socket.nativeCreateConnect( |
| 302 address._sockaddr_storage, port); | 302 address._sockaddr_storage, port); |
| 303 if (result is OSError) { | 303 if (result is OSError) { |
| 304 throw createError(result, "Connection failed", address, port); | 304 throw createError(result, "Connection failed", address, port); |
| 305 } else { | 305 } else { |
| 306 socket.port; // Query the local port, for error messages. |
| 306 var completer = new Completer(); | 307 var completer = new Completer(); |
| 307 // Setup handlers for receiving the first write event which | 308 // Setup handlers for receiving the first write event which |
| 308 // indicate that the socket is fully connected. | 309 // indicate that the socket is fully connected. |
| 309 socket.setHandlers( | 310 socket.setHandlers( |
| 310 write: () { | 311 write: () { |
| 311 socket.setListening(read: false, write: false); | 312 socket.setListening(read: false, write: false); |
| 312 completer.complete(socket); | 313 completer.complete(socket); |
| 313 }, | 314 }, |
| 314 error: (e) { | 315 error: (e) { |
| 315 socket.close(); | 316 socket.close(); |
| 316 completer.completeError( | 317 completer.completeError(e); |
| 317 createError(e, "Connection failed", address, port)); | |
| 318 } | 318 } |
| 319 ); | 319 ); |
| 320 socket.setListening(read: false, write: true); | 320 socket.setListening(read: false, write: true); |
| 321 return completer.future; | 321 return completer.future; |
| 322 } | 322 } |
| 323 }); | 323 }); |
| 324 } | 324 } |
| 325 | 325 |
| 326 static Future<_NativeSocket> bind(host, | 326 static Future<_NativeSocket> bind(host, |
| 327 int port, | 327 int port, |
| (...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1218 if (_detachReady != null) { | 1218 if (_detachReady != null) { |
| 1219 _detachReady.complete(null); | 1219 _detachReady.complete(null); |
| 1220 } else { | 1220 } else { |
| 1221 if (_raw != null) { | 1221 if (_raw != null) { |
| 1222 _raw.shutdown(SocketDirection.SEND); | 1222 _raw.shutdown(SocketDirection.SEND); |
| 1223 _disableWriteEvent(); | 1223 _disableWriteEvent(); |
| 1224 } | 1224 } |
| 1225 } | 1225 } |
| 1226 } | 1226 } |
| 1227 } | 1227 } |
| OLD | NEW |