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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 } | 388 } |
389 | 389 |
390 _read(int len) native "Socket_Read"; | 390 _read(int len) native "Socket_Read"; |
391 | 391 |
392 int readList(List<int> buffer, int offset, int bytes) { | 392 int readList(List<int> buffer, int offset, int bytes) { |
393 if (!_closed) { | 393 if (!_closed) { |
394 if (bytes == 0) { | 394 if (bytes == 0) { |
395 return 0; | 395 return 0; |
396 } | 396 } |
397 if (offset < 0) { | 397 if (offset < 0) { |
398 throw new IndexOutOfRangeException(offset); | 398 throw new RangeError.value(offset); |
399 } | 399 } |
400 if (bytes < 0) { | 400 if (bytes < 0) { |
401 throw new IndexOutOfRangeException(bytes); | 401 throw new RangeError.value(bytes); |
402 } | 402 } |
403 if ((offset + bytes) > buffer.length) { | 403 if ((offset + bytes) > buffer.length) { |
404 throw new IndexOutOfRangeException(offset + bytes); | 404 throw new RangeError.value(offset + bytes); |
405 } | 405 } |
406 var result = _readList(buffer, offset, bytes); | 406 var result = _readList(buffer, offset, bytes); |
407 if (result is OSError) { | 407 if (result is OSError) { |
408 _reportError(result, "Read failed"); | 408 _reportError(result, "Read failed"); |
409 return -1; | 409 return -1; |
410 } | 410 } |
411 return result; | 411 return result; |
412 } | 412 } |
413 throw new | 413 throw new |
414 SocketIOException("Error: readList failed - invalid socket handle"); | 414 SocketIOException("Error: readList failed - invalid socket handle"); |
415 } | 415 } |
416 | 416 |
417 _readList(List<int> buffer, int offset, int bytes) native "Socket_ReadList"; | 417 _readList(List<int> buffer, int offset, int bytes) native "Socket_ReadList"; |
418 | 418 |
419 int writeList(List<int> buffer, int offset, int bytes) { | 419 int writeList(List<int> buffer, int offset, int bytes) { |
420 if (buffer is! List || offset is! int || bytes is! int) { | 420 if (buffer is! List || offset is! int || bytes is! int) { |
421 throw new ArgumentError( | 421 throw new ArgumentError( |
422 "Invalid arguments to writeList on Socket"); | 422 "Invalid arguments to writeList on Socket"); |
423 } | 423 } |
424 if (!_closed) { | 424 if (!_closed) { |
425 if (bytes == 0) { | 425 if (bytes == 0) { |
426 return 0; | 426 return 0; |
427 } | 427 } |
428 if (offset < 0) { | 428 if (offset < 0) { |
429 throw new IndexOutOfRangeException(offset); | 429 throw new RangeError.value(offset); |
430 } | 430 } |
431 if (bytes < 0) { | 431 if (bytes < 0) { |
432 throw new IndexOutOfRangeException(bytes); | 432 throw new RangeError.value(bytes); |
433 } | 433 } |
434 if ((offset + bytes) > buffer.length) { | 434 if ((offset + bytes) > buffer.length) { |
435 throw new IndexOutOfRangeException(offset + bytes); | 435 throw new RangeError.value(offset + bytes); |
436 } | 436 } |
437 _BufferAndOffset bufferAndOffset = | 437 _BufferAndOffset bufferAndOffset = |
438 _ensureFastAndSerializableBuffer(buffer, offset, bytes); | 438 _ensureFastAndSerializableBuffer(buffer, offset, bytes); |
439 var result = | 439 var result = |
440 _writeList(bufferAndOffset.buffer, bufferAndOffset.offset, bytes); | 440 _writeList(bufferAndOffset.buffer, bufferAndOffset.offset, bytes); |
441 if (result is OSError) { | 441 if (result is OSError) { |
442 _reportError(result, "Write failed"); | 442 _reportError(result, "Write failed"); |
443 // If writing fails we return 0 as the number of bytes and | 443 // If writing fails we return 0 as the number of bytes and |
444 // report the error on the error handler. | 444 // report the error on the error handler. |
445 result = 0; | 445 result = 0; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 bool _seenFirstOutEvent = false; | 598 bool _seenFirstOutEvent = false; |
599 bool _pipe = false; | 599 bool _pipe = false; |
600 Function _clientConnectHandler; | 600 Function _clientConnectHandler; |
601 Function _clientWriteHandler; | 601 Function _clientWriteHandler; |
602 _SocketInputStream _inputStream; | 602 _SocketInputStream _inputStream; |
603 _SocketOutputStream _outputStream; | 603 _SocketOutputStream _outputStream; |
604 String _remoteHost; | 604 String _remoteHost; |
605 int _remotePort; | 605 int _remotePort; |
606 static SendPort _socketService; | 606 static SendPort _socketService; |
607 } | 607 } |
OLD | NEW |