@Test public void testRead_3args() throws Exception { System.out.println("read"); ByteBuffer[] dsts = null; int offset = 0; int length = 0; SocketChannel instance = new SocketChannelWithTimeoutsEmul(); try { long result = instance.read(dsts, offset, length); Assert.fail("Unimplemented expected"); } catch (UnsupportedOperationException e) { } }
@Override public int read(ByteBuffer dst) throws IOException { int bytesRead = 0; while (selector.select(readTimeout) > 0) { selector.selectedKeys().remove(channelKey); int cnt = socketChannel.read(dst); if (cnt < 1) { if (bytesRead < 1) { bytesRead = -1; } return bytesRead; } else { bytesRead += cnt; if (!fastFirstPacketRead) { fastFirstPacketRead = true; return bytesRead; } } } throw new SocketTimeoutException("Timeout exceeded while reading from socket"); }
SocketChannelWithTimeouts extends SocketChannel { @Override public int read(ByteBuffer dst) throws IOException { int bytesRead = 0; while (selector.select(readTimeout) > 0) { selector.selectedKeys().remove(channelKey); int cnt = socketChannel.read(dst); if (cnt < 1) { if (bytesRead < 1) { bytesRead = -1; } return bytesRead; } else { bytesRead += cnt; if (!fastFirstPacketRead) { fastFirstPacketRead = true; return bytesRead; } } } throw new SocketTimeoutException("Timeout exceeded while reading from socket"); } }
SocketChannelWithTimeouts extends SocketChannel { @Override public int read(ByteBuffer dst) throws IOException { int bytesRead = 0; while (selector.select(readTimeout) > 0) { selector.selectedKeys().remove(channelKey); int cnt = socketChannel.read(dst); if (cnt < 1) { if (bytesRead < 1) { bytesRead = -1; } return bytesRead; } else { bytesRead += cnt; if (!fastFirstPacketRead) { fastFirstPacketRead = true; return bytesRead; } } } throw new SocketTimeoutException("Timeout exceeded while reading from socket"); } protected  SocketChannelWithTimeouts(); }
SocketChannelWithTimeouts extends SocketChannel { @Override public int read(ByteBuffer dst) throws IOException { int bytesRead = 0; while (selector.select(readTimeout) > 0) { selector.selectedKeys().remove(channelKey); int cnt = socketChannel.read(dst); if (cnt < 1) { if (bytesRead < 1) { bytesRead = -1; } return bytesRead; } else { bytesRead += cnt; if (!fastFirstPacketRead) { fastFirstPacketRead = true; return bytesRead; } } } throw new SocketTimeoutException("Timeout exceeded while reading from socket"); } protected  SocketChannelWithTimeouts(); static SocketChannel open(); @Override SocketChannel bind(SocketAddress socketAddress); @Override SocketAddress getLocalAddress(); @Override SocketChannel setOption(SocketOption<T> socketOption, T t); @Override T getOption(SocketOption<T> socketOption); @Override Set<SocketOption<?>> supportedOptions(); @Override SocketChannel shutdownInput(); @Override SocketChannel shutdownOutput(); @Override boolean connect(SocketAddress remote); @Override int read(ByteBuffer dst); @Override long read(ByteBuffer[] dsts, int offset, int length); @Override int write(ByteBuffer src); @Override long write(ByteBuffer[] srcs, int offset, int length); @Override Socket socket(); @Override boolean isConnected(); @Override boolean isConnectionPending(); @Override boolean finishConnect(); void setConnectTimeout(int t); void setReadTimeout(int t); SocketAddress getRemoteAddress(); }
SocketChannelWithTimeouts extends SocketChannel { @Override public int read(ByteBuffer dst) throws IOException { int bytesRead = 0; while (selector.select(readTimeout) > 0) { selector.selectedKeys().remove(channelKey); int cnt = socketChannel.read(dst); if (cnt < 1) { if (bytesRead < 1) { bytesRead = -1; } return bytesRead; } else { bytesRead += cnt; if (!fastFirstPacketRead) { fastFirstPacketRead = true; return bytesRead; } } } throw new SocketTimeoutException("Timeout exceeded while reading from socket"); } protected  SocketChannelWithTimeouts(); static SocketChannel open(); @Override SocketChannel bind(SocketAddress socketAddress); @Override SocketAddress getLocalAddress(); @Override SocketChannel setOption(SocketOption<T> socketOption, T t); @Override T getOption(SocketOption<T> socketOption); @Override Set<SocketOption<?>> supportedOptions(); @Override SocketChannel shutdownInput(); @Override SocketChannel shutdownOutput(); @Override boolean connect(SocketAddress remote); @Override int read(ByteBuffer dst); @Override long read(ByteBuffer[] dsts, int offset, int length); @Override int write(ByteBuffer src); @Override long write(ByteBuffer[] srcs, int offset, int length); @Override Socket socket(); @Override boolean isConnected(); @Override boolean isConnectionPending(); @Override boolean finishConnect(); void setConnectTimeout(int t); void setReadTimeout(int t); SocketAddress getRemoteAddress();  }