| 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 abstract class ServerSocket { | 5 abstract class ServerSocket { |
| 6 /** | 6 /** |
| 7 * Constructs a new server socket, binds it to a given address and port, | 7 * Constructs a new server socket, binds it to a given address and port, |
| 8 * and listens on it. | 8 * and listens on it. |
| 9 */ | 9 */ |
| 10 factory ServerSocket(String bindAddress, int port, int backlog) { | 10 external factory ServerSocket(String bindAddress, int port, int backlog); |
| 11 return new _ServerSocket(bindAddress, port, backlog); | |
| 12 } | |
| 13 | 11 |
| 14 /** | 12 /** |
| 15 * The connection handler gets called when there is a new incoming | 13 * The connection handler gets called when there is a new incoming |
| 16 * connection on the socket. | 14 * connection on the socket. |
| 17 */ | 15 */ |
| 18 void set onConnection(void callback(Socket connection)); | 16 void set onConnection(void callback(Socket connection)); |
| 19 | 17 |
| 20 /** | 18 /** |
| 21 * The error handler gets called when a socket error occurs. | 19 * The error handler gets called when a socket error occurs. |
| 22 */ | 20 */ |
| (...skipping 10 matching lines...) Expand all Loading... |
| 33 void close(); | 31 void close(); |
| 34 } | 32 } |
| 35 | 33 |
| 36 | 34 |
| 37 abstract class Socket { | 35 abstract class Socket { |
| 38 /** | 36 /** |
| 39 * Constructs a new socket and initiate connecting it to the given | 37 * Constructs a new socket and initiate connecting it to the given |
| 40 * host on the given port. The returned socket is not yet connected | 38 * host on the given port. The returned socket is not yet connected |
| 41 * but ready for registration of callbacks. | 39 * but ready for registration of callbacks. |
| 42 */ | 40 */ |
| 43 factory Socket(String host, int port) => new _Socket(host, port); | 41 external factory Socket(String host, int port); |
| 44 | 42 |
| 45 /** | 43 /** |
| 46 * Returns the number of received and non-read bytes in the socket that | 44 * Returns the number of received and non-read bytes in the socket that |
| 47 * can be read. | 45 * can be read. |
| 48 */ | 46 */ |
| 49 int available(); | 47 int available(); |
| 50 | 48 |
| 51 /** | 49 /** |
| 52 * Reads up to [count] bytes of data from the socket and stores them into | 50 * Reads up to [count] bytes of data from the socket and stores them into |
| 53 * buffer after buffer offset [offset]. The number of successfully read | 51 * buffer after buffer offset [offset]. The number of successfully read |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 sb.add(" ($osError)"); | 141 sb.add(" ($osError)"); |
| 144 } | 142 } |
| 145 } else if (osError != null) { | 143 } else if (osError != null) { |
| 146 sb.add(": $osError"); | 144 sb.add(": $osError"); |
| 147 } | 145 } |
| 148 return sb.toString(); | 146 return sb.toString(); |
| 149 } | 147 } |
| 150 final String message; | 148 final String message; |
| 151 final OSError osError; | 149 final OSError osError; |
| 152 } | 150 } |
| OLD | NEW |