int readInternal(ByteBuffer buf) throws IOException { int n = OS.read0(fd, ((DirectBuffer) buf).address() + buf.position(), buf.remaining()); if ((n == IOStatus.INTERRUPTED) && socketChannel.isOpen()) { // The system call was interrupted but the channel // is still open, so retry return 0; } int ret = IOStatus.normalize(n); if (ret > 0) buf.position(buf.position() + ret); else if (ret < 0) open = false; return ret; } }
int readInternal(ByteBuffer buf) throws IOException { int n = OS.read0(fd, ((DirectBuffer) buf).address() + buf.position(), buf.remaining()); if ((n == IOStatus.INTERRUPTED) && socketChannel.isOpen()) { // The system call was interrupted but the channel // is still open, so retry return 0; } int ret = IOStatus.normalize(n); if (ret > 0) buf.position(buf.position() + ret); else if (ret < 0) open = false; return ret; } }
private int writeInternal(ByteBuffer buf) throws IOException { int pos = buf.position(); int lim = buf.limit(); int len = lim <= pos ? 0 : lim - pos; int res = OS.write0(fd, ((DirectBuffer) buf).address() + pos, len); if (res > 0) buf.position(pos + res); if ((res == IOStatus.INTERRUPTED) && socketChannel.isOpen()) { // The system call was interrupted but the channel // is still open, so retry return 0; } res = IOStatus.normalize(res); if (res < 0) open = false; if (res <= 0 && !socketChannel.isOpen()) throw new AsynchronousCloseException(); return res; } }
private int writeInternal(ByteBuffer buf) throws IOException { int pos = buf.position(); int lim = buf.limit(); int len = lim <= pos ? 0 : lim - pos; int res = OS.write0(fd, ((DirectBuffer) buf).address() + pos, len); if (res > 0) buf.position(pos + res); if ((res == IOStatus.INTERRUPTED) && socketChannel.isOpen()) { // The system call was interrupted but the channel // is still open, so retry return 0; } res = IOStatus.normalize(res); if (res < 0) open = false; if (res <= 0 && !socketChannel.isOpen()) throw new AsynchronousCloseException(); return res; } }