private int readNonConnected(final UDPNIOConnection connection, Buffer buffer, final ReadResult<Buffer, SocketAddress> currentResult) throws IOException { final SocketAddress peerAddress; final int read; final DirectByteBufferRecord ioRecord = DirectByteBufferRecord.get(); try { final ByteBuffer directByteBuffer = ioRecord.allocate(buffer.limit()); final int initialBufferPos = directByteBuffer.position(); peerAddress = ((DatagramChannel) connection.getChannel()).receive( directByteBuffer); read = directByteBuffer.position() - initialBufferPos; if (read > 0) { directByteBuffer.flip(); buffer.put(directByteBuffer); } } finally { ioRecord.release(); } final boolean hasRead = (read > 0); if (hasRead && currentResult != null) { currentResult.setMessage(buffer); currentResult.setReadSize(currentResult.getReadSize() + read); currentResult.setSrcAddress(peerAddress); } return read; }
private int readNonConnected(final UDPNIOConnection connection, Buffer buffer, final ReadResult<Buffer, SocketAddress> currentResult) throws IOException { final SocketAddress peerAddress; final int read; final DirectByteBufferRecord ioRecord = DirectByteBufferRecord.get(); try { final ByteBuffer directByteBuffer = ioRecord.allocate(buffer.limit()); final int initialBufferPos = directByteBuffer.position(); peerAddress = ((DatagramChannel) connection.getChannel()).receive( directByteBuffer); read = directByteBuffer.position() - initialBufferPos; if (read > 0) { directByteBuffer.flip(); buffer.put(directByteBuffer); } } finally { ioRecord.release(); } final boolean hasRead = (read > 0); if (hasRead && currentResult != null) { currentResult.setMessage(buffer); currentResult.setReadSize(currentResult.getReadSize() + read); currentResult.setSrcAddress(peerAddress); } return read; }
private int readNonConnected(final UDPNIOConnection connection, Buffer buffer, final ReadResult<Buffer, SocketAddress> currentResult) throws IOException { final SocketAddress peerAddress; final int read; final DirectByteBufferRecord ioRecord = DirectByteBufferRecord.get(); try { final ByteBuffer directByteBuffer = ioRecord.allocate(buffer.limit()); final int initialBufferPos = directByteBuffer.position(); peerAddress = ((DatagramChannel) connection.getChannel()).receive( directByteBuffer); read = directByteBuffer.position() - initialBufferPos; if (read > 0) { directByteBuffer.flip(); buffer.put(directByteBuffer); } } finally { ioRecord.release(); } final boolean hasRead = (read > 0); if (hasRead && currentResult != null) { currentResult.setMessage(buffer); currentResult.setReadSize(currentResult.getReadSize() + read); currentResult.setSrcAddress(peerAddress); } return read; }
private int readNonConnected(final UDPNIOConnection connection, Buffer buffer, final ReadResult<Buffer, SocketAddress> currentResult) throws IOException { final SocketAddress peerAddress; final int read; final DirectByteBufferRecord ioRecord = DirectByteBufferRecord.get(); try { final ByteBuffer directByteBuffer = ioRecord.allocate(buffer.limit()); final int initialBufferPos = directByteBuffer.position(); peerAddress = ((DatagramChannel) connection.getChannel()).receive( directByteBuffer); read = directByteBuffer.position() - initialBufferPos; if (read > 0) { directByteBuffer.flip(); buffer.put(directByteBuffer); } } finally { ioRecord.release(); } final boolean hasRead = (read > 0); if (hasRead && currentResult != null) { currentResult.setMessage(buffer); currentResult.setReadSize(currentResult.getReadSize() + read); currentResult.setSrcAddress(peerAddress); } return read; }
private int readNonConnected(final UDPNIOConnection connection, Buffer buffer, final ReadResult<Buffer, SocketAddress> currentResult) throws IOException { final SocketAddress peerAddress; final int read; final DirectByteBufferRecord ioRecord = DirectByteBufferRecord.get(); try { final ByteBuffer directByteBuffer = ioRecord.allocate(buffer.limit()); final int initialBufferPos = directByteBuffer.position(); peerAddress = ((DatagramChannel) connection.getChannel()).receive( directByteBuffer); read = directByteBuffer.position() - initialBufferPos; if (read > 0) { directByteBuffer.flip(); buffer.put(directByteBuffer); } } finally { ioRecord.release(); } final boolean hasRead = (read > 0); if (hasRead && currentResult != null) { currentResult.setMessage(buffer); currentResult.setReadSize(currentResult.getReadSize() + read); currentResult.setSrcAddress(peerAddress); } return read; }
private int readNonConnected(final UDPNIOConnection connection, Buffer buffer, final ReadResult<Buffer, SocketAddress> currentResult) throws IOException { final SocketAddress peerAddress; final int read; final DirectByteBufferRecord ioRecord = DirectByteBufferRecord.get(); try { final ByteBuffer directByteBuffer = ioRecord.allocate(buffer.limit()); final int initialBufferPos = directByteBuffer.position(); peerAddress = ((DatagramChannel) connection.getChannel()).receive( directByteBuffer); read = directByteBuffer.position() - initialBufferPos; if (read > 0) { directByteBuffer.flip(); buffer.put(directByteBuffer); } } finally { ioRecord.release(); } final boolean hasRead = (read > 0); if (hasRead && currentResult != null) { currentResult.setMessage(buffer); currentResult.setReadSize(currentResult.getReadSize() + read); currentResult.setSrcAddress(peerAddress); } return read; }
private int readNonConnected(final UDPNIOConnection connection, Buffer buffer, final ReadResult<Buffer, SocketAddress> currentResult) throws IOException { final SocketAddress peerAddress; final int read; final DirectByteBufferRecord ioRecord = DirectByteBufferRecord.get(); try { final ByteBuffer directByteBuffer = ioRecord.allocate(buffer.limit()); final int initialBufferPos = directByteBuffer.position(); peerAddress = ((DatagramChannel) connection.getChannel()).receive( directByteBuffer); read = directByteBuffer.position() - initialBufferPos; if (read > 0) { directByteBuffer.flip(); buffer.put(directByteBuffer); } } finally { ioRecord.release(); } final boolean hasRead = (read > 0); if (hasRead && currentResult != null) { currentResult.setMessage(buffer); currentResult.setReadSize(currentResult.getReadSize() + read); currentResult.setSrcAddress(peerAddress); } return read; }
private int readNonConnected(final UDPNIOConnection connection, Buffer buffer, final ReadResult<Buffer, SocketAddress> currentResult) throws IOException { final SocketAddress peerAddress; final int read; final DirectByteBufferRecord ioRecord = DirectByteBufferRecord.get(); try { final ByteBuffer directByteBuffer = ioRecord.allocate(buffer.limit()); final int initialBufferPos = directByteBuffer.position(); peerAddress = ((DatagramChannel) connection.getChannel()).receive( directByteBuffer); read = directByteBuffer.position() - initialBufferPos; if (read > 0) { directByteBuffer.flip(); buffer.put(directByteBuffer); } } finally { ioRecord.release(); } final boolean hasRead = (read > 0); if (hasRead && currentResult != null) { currentResult.setMessage(buffer); currentResult.setReadSize(currentResult.getReadSize() + read); currentResult.setSrcAddress(peerAddress); } return read; }
private int readConnected(final UDPNIOConnection connection, Buffer buffer, final ReadResult<Buffer, SocketAddress> currentResult) throws IOException { final int read; final int oldPos = buffer.position(); if (buffer.isComposite()) { final ByteBufferArray array = buffer.toByteBufferArray(); final ByteBuffer[] byteBuffers = array.getArray(); final int size = array.size(); read = (int) ((DatagramChannel) connection.getChannel()).read(byteBuffers, 0, size); array.restore(); array.recycle(); } else { read = ((DatagramChannel) connection.getChannel()).read( buffer.toByteBuffer()); } final boolean hasRead = (read > 0); if (hasRead) { buffer.position(oldPos + read); } if (hasRead && currentResult != null) { currentResult.setMessage(buffer); currentResult.setReadSize(currentResult.getReadSize() + read); currentResult.setSrcAddressHolder(connection.peerSocketAddressHolder); } return read; }
private int readConnected(final UDPNIOConnection connection, Buffer buffer, final ReadResult<Buffer, SocketAddress> currentResult) throws IOException { final int read; final int oldPos = buffer.position(); if (buffer.isComposite()) { final ByteBufferArray array = buffer.toByteBufferArray(); final ByteBuffer[] byteBuffers = array.getArray(); final int size = array.size(); read = (int) ((DatagramChannel) connection.getChannel()).read(byteBuffers, 0, size); array.restore(); array.recycle(); } else { read = ((DatagramChannel) connection.getChannel()).read( buffer.toByteBuffer()); } final boolean hasRead = (read > 0); if (hasRead) { buffer.position(oldPos + read); } if (hasRead && currentResult != null) { currentResult.setMessage(buffer); currentResult.setReadSize(currentResult.getReadSize() + read); currentResult.setSrcAddressHolder(connection.peerSocketAddressHolder); } return read; }
private int readConnected(final UDPNIOConnection connection, Buffer buffer, final ReadResult<Buffer, SocketAddress> currentResult) throws IOException { final int read; final int oldPos = buffer.position(); if (buffer.isComposite()) { final ByteBufferArray array = buffer.toByteBufferArray(); final ByteBuffer[] byteBuffers = array.getArray(); final int size = array.size(); read = (int) ((DatagramChannel) connection.getChannel()).read(byteBuffers, 0, size); array.restore(); array.recycle(); } else { read = ((DatagramChannel) connection.getChannel()).read( buffer.toByteBuffer()); } final boolean hasRead = (read > 0); if (hasRead) { buffer.position(oldPos + read); } if (hasRead && currentResult != null) { currentResult.setMessage(buffer); currentResult.setReadSize(currentResult.getReadSize() + read); currentResult.setSrcAddressHolder(connection.peerSocketAddressHolder); } return read; }
private int readConnected(final UDPNIOConnection connection, Buffer buffer, final ReadResult<Buffer, SocketAddress> currentResult) throws IOException { final int read; final int oldPos = buffer.position(); if (buffer.isComposite()) { final ByteBufferArray array = buffer.toByteBufferArray(); final ByteBuffer[] byteBuffers = array.getArray(); final int size = array.size(); read = (int) ((DatagramChannel) connection.getChannel()).read(byteBuffers, 0, size); array.restore(); array.recycle(); } else { read = ((DatagramChannel) connection.getChannel()).read( buffer.toByteBuffer()); } final boolean hasRead = (read > 0); if (hasRead) { buffer.position(oldPos + read); } if (hasRead && currentResult != null) { currentResult.setMessage(buffer); currentResult.setReadSize(currentResult.getReadSize() + read); currentResult.setSrcAddressHolder(connection.peerSocketAddressHolder); } return read; }
private int readConnected(final UDPNIOConnection connection, Buffer buffer, final ReadResult<Buffer, SocketAddress> currentResult) throws IOException { final int read; final int oldPos = buffer.position(); if (buffer.isComposite()) { final ByteBufferArray array = buffer.toByteBufferArray(); final ByteBuffer[] byteBuffers = array.getArray(); final int size = array.size(); read = (int) ((DatagramChannel) connection.getChannel()).read(byteBuffers, 0, size); array.restore(); array.recycle(); } else { read = ((DatagramChannel) connection.getChannel()).read( buffer.toByteBuffer()); } final boolean hasRead = (read > 0); if (hasRead) { buffer.position(oldPos + read); } if (hasRead && currentResult != null) { currentResult.setMessage(buffer); currentResult.setReadSize(currentResult.getReadSize() + read); currentResult.setSrcAddressHolder(connection.peerSocketAddressHolder); } return read; }
private int readConnected(final UDPNIOConnection connection, Buffer buffer, final ReadResult<Buffer, SocketAddress> currentResult) throws IOException { final int read; final int oldPos = buffer.position(); if (buffer.isComposite()) { final ByteBufferArray array = buffer.toByteBufferArray(); final ByteBuffer[] byteBuffers = array.getArray(); final int size = array.size(); read = (int) ((DatagramChannel) connection.getChannel()).read(byteBuffers, 0, size); array.restore(); array.recycle(); } else { read = ((DatagramChannel) connection.getChannel()).read( buffer.toByteBuffer()); } final boolean hasRead = (read > 0); if (hasRead) { buffer.position(oldPos + read); } if (hasRead && currentResult != null) { currentResult.setMessage(buffer); currentResult.setReadSize(currentResult.getReadSize() + read); currentResult.setSrcAddressHolder(connection.peerSocketAddressHolder); } return read; }
private int readConnected(final UDPNIOConnection connection, Buffer buffer, final ReadResult<Buffer, SocketAddress> currentResult) throws IOException { final int read; final int oldPos = buffer.position(); if (buffer.isComposite()) { final ByteBufferArray array = buffer.toByteBufferArray(); final ByteBuffer[] byteBuffers = array.getArray(); final int size = array.size(); read = (int) ((DatagramChannel) connection.getChannel()).read(byteBuffers, 0, size); array.restore(); array.recycle(); } else { read = ((DatagramChannel) connection.getChannel()).read( buffer.toByteBuffer()); } final boolean hasRead = (read > 0); if (hasRead) { buffer.position(oldPos + read); } if (hasRead && currentResult != null) { currentResult.setMessage(buffer); currentResult.setReadSize(currentResult.getReadSize() + read); currentResult.setSrcAddressHolder(connection.peerSocketAddressHolder); } return read; }
private int readConnected(final UDPNIOConnection connection, Buffer buffer, final ReadResult<Buffer, SocketAddress> currentResult) throws IOException { final int read; final int oldPos = buffer.position(); if (buffer.isComposite()) { final ByteBufferArray array = buffer.toByteBufferArray(); final ByteBuffer[] byteBuffers = array.getArray(); final int size = array.size(); read = (int) ((DatagramChannel) connection.getChannel()).read(byteBuffers, 0, size); array.restore(); array.recycle(); } else { read = ((DatagramChannel) connection.getChannel()).read( buffer.toByteBuffer()); } final boolean hasRead = (read > 0); if (hasRead) { buffer.position(oldPos + read); } if (hasRead && currentResult != null) { currentResult.setMessage(buffer); currentResult.setReadSize(currentResult.getReadSize() + read); currentResult.setSrcAddressHolder(connection.peerSocketAddressHolder); } return read; }
private int readConnected(final UDPNIOConnection connection, Buffer buffer, final ReadResult<Buffer, SocketAddress> currentResult) throws IOException { final int read; final int oldPos = buffer.position(); if (buffer.isComposite()) { final ByteBufferArray array = buffer.toByteBufferArray(); final ByteBuffer[] byteBuffers = array.getArray(); final int size = array.size(); read = (int) ((DatagramChannel) connection.getChannel()).read(byteBuffers, 0, size); array.restore(); array.recycle(); } else { read = ((DatagramChannel) connection.getChannel()).read( buffer.toByteBuffer()); } final boolean hasRead = (read > 0); if (hasRead) { buffer.position(oldPos + read); } if (hasRead && currentResult != null) { currentResult.setMessage(buffer); currentResult.setReadSize(currentResult.getReadSize() + read); currentResult.setSrcAddressHolder(connection.peerSocketAddressHolder); } return read; }
private int readConnected(final UDPNIOConnection connection, Buffer buffer, final ReadResult<Buffer, SocketAddress> currentResult) throws IOException { final int read; final int oldPos = buffer.position(); if (buffer.isComposite()) { final ByteBufferArray array = buffer.toByteBufferArray(); final ByteBuffer[] byteBuffers = array.getArray(); final int size = array.size(); read = (int) ((DatagramChannel) connection.getChannel()).read(byteBuffers, 0, size); array.restore(); array.recycle(); } else { read = ((DatagramChannel) connection.getChannel()).read( buffer.toByteBuffer()); } final boolean hasRead = (read > 0); if (hasRead) { buffer.position(oldPos + read); } if (hasRead && currentResult != null) { currentResult.setMessage(buffer); currentResult.setReadSize(currentResult.getReadSize() + read); currentResult.setSrcAddressHolder(connection.peerSocketAddressHolder); } return read; }
private int readConnected(final UDPNIOConnection connection, Buffer buffer, final ReadResult<Buffer, SocketAddress> currentResult) throws IOException { final int read; final int oldPos = buffer.position(); if (buffer.isComposite()) { final ByteBufferArray array = buffer.toByteBufferArray(); final ByteBuffer[] byteBuffers = array.getArray(); final int size = array.size(); read = (int) ((DatagramChannel) connection.getChannel()).read(byteBuffers, 0, size); array.restore(); array.recycle(); } else { read = ((DatagramChannel) connection.getChannel()).read( buffer.toByteBuffer()); } final boolean hasRead = (read > 0); if (hasRead) { buffer.position(oldPos + read); } if (hasRead && currentResult != null) { currentResult.setMessage(buffer); currentResult.setReadSize(currentResult.getReadSize() + read); currentResult.setSrcAddressHolder(connection.peerSocketAddressHolder); } return read; }
private int readConnected(final UDPNIOConnection connection, Buffer buffer, final ReadResult<Buffer, SocketAddress> currentResult) throws IOException { final int read; final int oldPos = buffer.position(); if (buffer.isComposite()) { final ByteBufferArray array = buffer.toByteBufferArray(); final ByteBuffer[] byteBuffers = array.getArray(); final int size = array.size(); read = (int) ((DatagramChannel) connection.getChannel()).read(byteBuffers, 0, size); array.restore(); array.recycle(); } else { read = ((DatagramChannel) connection.getChannel()).read( buffer.toByteBuffer()); } final boolean hasRead = (read > 0); if (hasRead) { buffer.position(oldPos + read); } if (hasRead && currentResult != null) { currentResult.setMessage(buffer); currentResult.setReadSize(currentResult.getReadSize() + read); currentResult.setSrcAddressHolder(connection.peerSocketAddressHolder); } return read; }