private void doRecv(DatagramPacket pack, int flags) throws IOException { IoBridge.recvfrom(false, fd, pack.getData(), pack.getOffset(), pack.getLength(), flags, pack, isNativeConnected); if (isNativeConnected) { updatePacketRecvAddress(pack); } }
/** * For PlainSocketInputStream. */ private int read(byte[] buffer, int offset, int byteCount) throws IOException { if (byteCount == 0) { return 0; } Arrays.checkOffsetAndCount(buffer.length, offset, byteCount); if (shutdownInput) { return -1; } int readCount = IoBridge.recvfrom(true, fd, buffer, offset, byteCount, 0, null, false); // Return of zero bytes for a blocking socket means a timeout occurred if (readCount == 0) { throw new SocketTimeoutException(); } // Return of -1 indicates the peer was closed if (readCount == -1) { shutdownInput = true; } return readCount; }
private SocketAddress receiveDirectImpl(ByteBuffer target, boolean loop) throws IOException { SocketAddress retAddr = null; DatagramPacket receivePacket = new DatagramPacket(EmptyArray.BYTE, 0); int oldposition = target.position(); int received = 0; do { received = IoBridge.recvfrom(false, fd, target, 0, receivePacket, isConnected()); if (receivePacket != null && receivePacket.getAddress() != null) { // copy the data of received packet if (received > 0) { target.position(oldposition + received); } retAddr = receivePacket.getSocketAddress(); break; } } while (loop); return retAddr; }
private SocketAddress receiveImpl(ByteBuffer target, boolean loop) throws IOException { SocketAddress retAddr = null; DatagramPacket receivePacket; int oldposition = target.position(); int received = 0; // TODO: disallow mapped buffers and lose this conditional? if (target.hasArray()) { receivePacket = new DatagramPacket(target.array(), target.position() + target.arrayOffset(), target.remaining()); } else { receivePacket = new DatagramPacket(new byte[target.remaining()], target.remaining()); } do { received = IoBridge.recvfrom(false, fd, receivePacket.getData(), receivePacket.getOffset(), receivePacket.getLength(), 0, receivePacket, isConnected()); if (receivePacket != null && receivePacket.getAddress() != null) { if (received > 0) { if (target.hasArray()) { target.position(oldposition + received); } else { // copy the data of received packet target.put(receivePacket.getData(), 0, received); } } retAddr = receivePacket.getSocketAddress(); break; } } while (loop); return retAddr; }
private int readImpl(ByteBuffer dst) throws IOException { synchronized (readLock) { int readCount = 0; try { if (isBlocking()) { begin(); } readCount = IoBridge.recvfrom(true, fd, dst, 0, null, false); if (readCount > 0) { dst.position(dst.position() + readCount); } } finally { if (isBlocking()) { end(readCount > 0); } } return readCount; } }
private int readImpl(ByteBuffer dst) throws IOException { synchronized (readLock) { int readCount = 0; try { begin(); readCount = IoBridge.recvfrom(false, fd, dst, 0, null, isConnected()); } catch (InterruptedIOException e) { // InterruptedIOException will be thrown when timeout. return 0; } finally { end(readCount > 0); } return readCount; } }
private void doRecv(DatagramPacket pack, int flags) throws IOException { IoBridge.recvfrom(false, fd, pack.getData(), pack.getOffset(), pack.getLength(), flags, pack, isNativeConnected); if (isNativeConnected) { updatePacketRecvAddress(pack); } }
private void doRecv(DatagramPacket pack, int flags) throws IOException { IoBridge.recvfrom(false, fd, pack.getData(), pack.getOffset(), pack.getLength(), flags, pack, isNativeConnected); if (isNativeConnected) { updatePacketRecvAddress(pack); } }
private void doRecv(DatagramPacket pack, int flags) throws IOException { IoBridge.recvfrom(false, fd, pack.getData(), pack.getOffset(), pack.getLength(), flags, pack, isNativeConnected); if (isNativeConnected) { updatePacketRecvAddress(pack); } }
private void doRecv(DatagramPacket pack, int flags) throws IOException { IoBridge.recvfrom(false, fd, pack.getData(), pack.getOffset(), pack.getLength(), flags, pack, isNativeConnected); if (isNativeConnected) { updatePacketRecvAddress(pack); } }
private void doRecv(DatagramPacket pack, int flags) throws IOException { IoBridge.recvfrom(false, fd, pack.getData(), pack.getOffset(), pack.getLength(), flags, pack, isNativeConnected); if (isNativeConnected) { updatePacketRecvAddress(pack); } }
private SocketAddress receiveDirectImpl(ByteBuffer target, boolean loop) throws IOException { SocketAddress retAddr = null; DatagramPacket receivePacket = new DatagramPacket(EmptyArray.BYTE, 0); int oldposition = target.position(); int received = 0; do { received = IoBridge.recvfrom(false, fd, target, 0, receivePacket, isConnected()); if (receivePacket != null && receivePacket.getAddress() != null) { // copy the data of received packet if (received > 0) { target.position(oldposition + received); } retAddr = receivePacket.getSocketAddress(); break; } } while (loop); return retAddr; }
private void doRecv(DatagramPacket pack, int flags) throws IOException { IoBridge.recvfrom(false, fd, pack.getData(), pack.getOffset(), pack.getLength(), flags, pack, isNativeConnected); if (isNativeConnected) { updatePacketRecvAddress(pack); } }
private int readImpl(ByteBuffer dst) throws IOException { synchronized (readLock) { int readCount = 0; try { if (isBlocking()) { begin(); } readCount = IoBridge.recvfrom(true, fd, dst, 0, null, false); if (readCount > 0) { dst.position(dst.position() + readCount); } } finally { if (isBlocking()) { end(readCount > 0); } } return readCount; } }
private int readImpl(ByteBuffer dst) throws IOException { synchronized (readLock) { int readCount = 0; try { if (isBlocking()) { begin(); } readCount = IoBridge.recvfrom(true, fd, dst, 0, null, false); if (readCount > 0) { dst.position(dst.position() + readCount); } } finally { if (isBlocking()) { end(readCount > 0); } } return readCount; } }
private int readImpl(ByteBuffer dst) throws IOException { synchronized (readLock) { int readCount = 0; try { begin(); readCount = IoBridge.recvfrom(false, fd, dst, 0, null, isConnected()); } catch (InterruptedIOException e) { // InterruptedIOException will be thrown when timeout. return 0; } finally { end(readCount > 0); } return readCount; } }
private int readImpl(ByteBuffer dst) throws IOException { synchronized (readLock) { int readCount = 0; try { begin(); readCount = IoBridge.recvfrom(false, fd, dst, 0, null, isConnected()); } catch (InterruptedIOException e) { // InterruptedIOException will be thrown when timeout. return 0; } finally { end(readCount > 0); } return readCount; } }
private int readImpl(ByteBuffer dst) throws IOException { synchronized (readLock) { int readCount = 0; try { begin(); readCount = IoBridge.recvfrom(false, fd, dst, 0, null, isConnected()); } catch (InterruptedIOException e) { // InterruptedIOException will be thrown when timeout. return 0; } finally { end(readCount > 0); } return readCount; } }
private int readImpl(ByteBuffer dst) throws IOException { synchronized (readLock) { int readCount = 0; try { begin(); readCount = IoBridge.recvfrom(false, fd, dst, 0, null, isConnected()); } catch (InterruptedIOException e) { // InterruptedIOException will be thrown when timeout. return 0; } finally { end(readCount > 0); } return readCount; } }
private int readImpl(ByteBuffer dst) throws IOException { synchronized (readLock) { int readCount = 0; try { begin(); readCount = IoBridge.recvfrom(false, fd, dst, 0, null, isConnected()); } catch (InterruptedIOException e) { // InterruptedIOException will be thrown when timeout. return 0; } finally { end(readCount > 0); } return readCount; } }