| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 | 5 |
| 6 class _SocketBase { | 6 class _SocketBase { |
| 7 // Bit flags used when communicating between the eventhandler and | 7 // Bit flags used when communicating between the eventhandler and |
| 8 // dart code. The EVENT flags are used to indicate events of | 8 // dart code. The EVENT flags are used to indicate events of |
| 9 // interest when sending a message from dart code to the | 9 // interest when sending a message from dart code to the |
| 10 // eventhandler. When receiving a message from the eventhandler the | 10 // eventhandler. When receiving a message from the eventhandler the |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 /* | 194 /* |
| 195 * Constructor for server socket. First a socket object is allocated | 195 * Constructor for server socket. First a socket object is allocated |
| 196 * in which the native socket is stored. After that _createBind | 196 * in which the native socket is stored. After that _createBind |
| 197 * is called which creates a file descriptor and binds the given address | 197 * is called which creates a file descriptor and binds the given address |
| 198 * and port to the socket. Null is returned if file descriptor creation or | 198 * and port to the socket. Null is returned if file descriptor creation or |
| 199 * bind failed. | 199 * bind failed. |
| 200 */ | 200 */ |
| 201 factory _ServerSocket(String bindAddress, int port, int backlog) { | 201 factory _ServerSocket(String bindAddress, int port, int backlog) { |
| 202 ServerSocket socket = new _ServerSocket._internal(); | 202 ServerSocket socket = new _ServerSocket._internal(); |
| 203 if (!socket._createBindListen(bindAddress, port, backlog)) { | 203 if (!socket._createBindListen(bindAddress, port, backlog)) { |
| 204 socket.close(); |
| 204 return null; | 205 return null; |
| 205 } | 206 } |
| 206 if (port != 0) { | 207 if (port != 0) { |
| 207 socket._port = port; | 208 socket._port = port; |
| 208 } | 209 } |
| 209 return socket; | 210 return socket; |
| 210 } | 211 } |
| 211 | 212 |
| 212 _ServerSocket._internal(); | 213 _ServerSocket._internal(); |
| 213 | 214 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 240 /* | 241 /* |
| 241 * Constructor for socket. First a socket object is allocated | 242 * Constructor for socket. First a socket object is allocated |
| 242 * in which the native socket is stored. After that _createConnect is | 243 * in which the native socket is stored. After that _createConnect is |
| 243 * called which creates a file discriptor and connects to the given | 244 * called which creates a file discriptor and connects to the given |
| 244 * host on the given port. Null is returned if file descriptor creation | 245 * host on the given port. Null is returned if file descriptor creation |
| 245 * or connect failed. | 246 * or connect failed. |
| 246 */ | 247 */ |
| 247 factory _Socket(String host, int port) { | 248 factory _Socket(String host, int port) { |
| 248 Socket socket = new _Socket._internal(); | 249 Socket socket = new _Socket._internal(); |
| 249 if (!socket._createConnect(host, port)) { | 250 if (!socket._createConnect(host, port)) { |
| 251 socket.close(); |
| 250 return null; | 252 return null; |
| 251 } | 253 } |
| 252 return socket; | 254 return socket; |
| 253 } | 255 } |
| 254 | 256 |
| 255 _Socket._internal(); | 257 _Socket._internal(); |
| 256 _Socket._internalInputOnly() : _closedRead = true; | 258 _Socket._internalInputOnly() : _closedRead = true; |
| 257 _Socket._internalOutputOnly() : _closedWrite = true; | 259 _Socket._internalOutputOnly() : _closedWrite = true; |
| 258 | 260 |
| 259 int available() { | 261 int available() { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 } | 349 } |
| 348 return _outputStream; | 350 return _outputStream; |
| 349 } | 351 } |
| 350 | 352 |
| 351 bool _closedRead = false; | 353 bool _closedRead = false; |
| 352 bool _closedWrite = false; | 354 bool _closedWrite = false; |
| 353 SocketInputStream _inputStream; | 355 SocketInputStream _inputStream; |
| 354 SocketOutputStream _outputStream; | 356 SocketOutputStream _outputStream; |
| 355 } | 357 } |
| 356 | 358 |
| OLD | NEW |