| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 ServerSocket { | 5 patch class ServerSocket { |
| 6 /* patch */ factory ServerSocket(String bindAddress, int port, int backlog) { | 6 /* patch */ factory ServerSocket(String bindAddress, int port, int backlog) { |
| 7 return new _ServerSocket(bindAddress, port, backlog); | 7 return new _ServerSocket(bindAddress, port, backlog); |
| 8 } | 8 } |
| 9 } | 9 } |
| 10 | 10 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 static const int _LISTENING_SOCKET = 16; | 125 static const int _LISTENING_SOCKET = 16; |
| 126 static const int _PIPE = 17; | 126 static const int _PIPE = 17; |
| 127 | 127 |
| 128 static const int _FIRST_EVENT = _IN_EVENT; | 128 static const int _FIRST_EVENT = _IN_EVENT; |
| 129 static const int _LAST_EVENT = _CLOSE_EVENT; | 129 static const int _LAST_EVENT = _CLOSE_EVENT; |
| 130 | 130 |
| 131 static const int _FIRST_COMMAND = _CLOSE_COMMAND; | 131 static const int _FIRST_COMMAND = _CLOSE_COMMAND; |
| 132 static const int _LAST_COMMAND = _SHUTDOWN_WRITE_COMMAND; | 132 static const int _LAST_COMMAND = _SHUTDOWN_WRITE_COMMAND; |
| 133 | 133 |
| 134 _SocketBase () { | 134 _SocketBase () { |
| 135 _handlerMap = new List(_LAST_EVENT + 1); | 135 _handlerMap = new List.fixedLength(_LAST_EVENT + 1); |
| 136 _handlerMask = 0; | 136 _handlerMask = 0; |
| 137 _canActivateHandlers = true; | 137 _canActivateHandlers = true; |
| 138 _closed = true; | 138 _closed = true; |
| 139 _EventHandler._start(); | 139 _EventHandler._start(); |
| 140 _hashCode = _nextHashCode; | 140 _hashCode = _nextHashCode; |
| 141 _nextHashCode = (_nextHashCode + 1) & 0xFFFFFFF; | 141 _nextHashCode = (_nextHashCode + 1) & 0xFFFFFFF; |
| 142 } | 142 } |
| 143 | 143 |
| 144 // Multiplexes socket events to the socket handlers. | 144 // Multiplexes socket events to the socket handlers. |
| 145 void _multiplex(int event_mask) { | 145 void _multiplex(int event_mask) { |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 | 415 |
| 416 class _Socket extends _SocketBase implements Socket { | 416 class _Socket extends _SocketBase implements Socket { |
| 417 static const HOST_NAME_LOOKUP = 0; | 417 static const HOST_NAME_LOOKUP = 0; |
| 418 | 418 |
| 419 // Constructs a new socket. During the construction an asynchronous | 419 // Constructs a new socket. During the construction an asynchronous |
| 420 // host name lookup is initiated. The returned socket is not yet | 420 // host name lookup is initiated. The returned socket is not yet |
| 421 // connected but ready for registration of callbacks. | 421 // connected but ready for registration of callbacks. |
| 422 factory _Socket(String host, int port) { | 422 factory _Socket(String host, int port) { |
| 423 Socket socket = new _Socket._internal(); | 423 Socket socket = new _Socket._internal(); |
| 424 _ensureSocketService(); | 424 _ensureSocketService(); |
| 425 List request = new List(2); | 425 List request = new List.fixedLength(2); |
| 426 request[0] = HOST_NAME_LOOKUP; | 426 request[0] = HOST_NAME_LOOKUP; |
| 427 request[1] = host; | 427 request[1] = host; |
| 428 _socketService.call(request).then((response) { | 428 _socketService.call(request).then((response) { |
| 429 if (socket._isErrorResponse(response)) { | 429 if (socket._isErrorResponse(response)) { |
| 430 socket._reportError(response, "Failed host name lookup"); | 430 socket._reportError(response, "Failed host name lookup"); |
| 431 } else{ | 431 } else{ |
| 432 var result = socket._createConnect(response, port); | 432 var result = socket._createConnect(response, port); |
| 433 if (result is OSError) { | 433 if (result is OSError) { |
| 434 socket.close(); | 434 socket.close(); |
| 435 socket._reportError(result, "Connection failed"); | 435 socket._reportError(result, "Connection failed"); |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 bool _seenFirstOutEvent = false; | 685 bool _seenFirstOutEvent = false; |
| 686 bool _pipe = false; | 686 bool _pipe = false; |
| 687 Function _clientConnectHandler; | 687 Function _clientConnectHandler; |
| 688 Function _clientWriteHandler; | 688 Function _clientWriteHandler; |
| 689 _SocketInputStream _inputStream; | 689 _SocketInputStream _inputStream; |
| 690 _SocketOutputStream _outputStream; | 690 _SocketOutputStream _outputStream; |
| 691 String _remoteHost; | 691 String _remoteHost; |
| 692 int _remotePort; | 692 int _remotePort; |
| 693 static SendPort _socketService; | 693 static SendPort _socketService; |
| 694 } | 694 } |
| OLD | NEW |