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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 // Socket close state | 199 // Socket close state |
200 bool isClosed = false; | 200 bool isClosed = false; |
201 bool isClosing = false; | 201 bool isClosing = false; |
202 bool isClosedRead = false; | 202 bool isClosedRead = false; |
203 bool isClosedWrite = false; | 203 bool isClosedWrite = false; |
204 Completer closeCompleter = new Completer(); | 204 Completer closeCompleter = new Completer(); |
205 | 205 |
206 // Handlers and receive port for socket events from the event handler. | 206 // Handlers and receive port for socket events from the event handler. |
207 int eventMask = 0; | 207 int eventMask = 0; |
208 List eventHandlers; | 208 List eventHandlers; |
209 ReceivePort eventPort; | 209 RawReceivePort eventPort; |
210 | 210 |
211 // Indicates if native interrupts can be activated. | 211 // Indicates if native interrupts can be activated. |
212 bool canActivateEvents = true; | 212 bool canActivateEvents = true; |
213 | 213 |
214 // The type flags for this socket. | 214 // The type flags for this socket. |
215 final int typeFlags; | 215 final int typeFlags; |
216 | 216 |
217 // Holds the port of the socket, null if not known. | 217 // Holds the port of the socket, null if not known. |
218 int localPort; | 218 int localPort; |
219 | 219 |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 } | 581 } |
582 | 582 |
583 void sendToEventHandler(int data) { | 583 void sendToEventHandler(int data) { |
584 connectToEventHandler(); | 584 connectToEventHandler(); |
585 assert(!isClosed); | 585 assert(!isClosed); |
586 _EventHandler._sendData(this, eventPort, data); | 586 _EventHandler._sendData(this, eventPort, data); |
587 } | 587 } |
588 | 588 |
589 void connectToEventHandler() { | 589 void connectToEventHandler() { |
590 if (eventPort == null) { | 590 if (eventPort == null) { |
591 eventPort = new ReceivePort(); | 591 eventPort = new RawReceivePort(multiplex); |
592 eventPort.receive ((var message, _) => multiplex(message)); | |
593 } | 592 } |
594 } | 593 } |
595 | 594 |
596 void disconnectFromEventHandler() { | 595 void disconnectFromEventHandler() { |
597 if (eventPort != null) { | 596 if (eventPort != null) { |
598 eventPort.close(); | 597 eventPort.close(); |
599 eventPort = null; | 598 eventPort = null; |
600 } | 599 } |
601 } | 600 } |
602 | 601 |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 if (_detachReady != null) { | 1214 if (_detachReady != null) { |
1216 _detachReady.complete(null); | 1215 _detachReady.complete(null); |
1217 } else { | 1216 } else { |
1218 if (_raw != null) { | 1217 if (_raw != null) { |
1219 _raw.shutdown(SocketDirection.SEND); | 1218 _raw.shutdown(SocketDirection.SEND); |
1220 _disableWriteEvent(); | 1219 _disableWriteEvent(); |
1221 } | 1220 } |
1222 } | 1221 } |
1223 } | 1222 } |
1224 } | 1223 } |
OLD | NEW |