public synchronized void close() throws IOException { /* * close the channel since Socket.getInputStream().close() * closes the socket. */ reader.channel.close(); reader.close(); }
/** * Create a new input stream with the given timeout. If the timeout * is zero, it will be treated as infinite timeout. The socket's * channel will be configured to be non-blocking. * * @param channel * Channel for reading, should also be a {@link SelectableChannel}. * The channel will be configured to be non-blocking. * @param timeout * timeout in milliseconds. must not be negative. * @throws IOException */ public SocketInputStream(ReadableByteChannel channel, long timeout) throws IOException { SocketIOWithTimeout.checkChannelValidity(channel); reader = new Reader(channel, timeout); }
/** * Create a new input stream with the given timeout. If the timeout * is zero, it will be treated as infinite timeout. The socket's * channel will be configured to be non-blocking. * * @param channel * Channel for reading, should also be a {@link SelectableChannel}. * The channel will be configured to be non-blocking. * @param timeout * timeout in milliseconds. must not be negative. * @throws IOException */ public SocketInputStream(ReadableByteChannel channel, long timeout) throws IOException { SocketIOWithTimeout.checkChannelValidity(channel); reader = new Reader(channel, timeout); }
public int read(ByteBuffer dst) throws IOException { return reader.doIO(dst, SelectionKey.OP_READ); }
public boolean isOpen() { return reader.isOpen(); }
/** * waits for the underlying channel to be ready for reading. * The timeout specified for this stream applies to this wait. * * @throws SocketTimeoutException * if select on the channel times out. * @throws IOException * if any other I/O error occurs. */ public void waitForReadable() throws IOException { reader.waitForIO(SelectionKey.OP_READ); } }
/** * waits for the underlying channel to be ready for reading. * The timeout specified for this stream applies to this wait. * * @throws SocketTimeoutException * if select on the channel times out. * @throws IOException * if any other I/O error occurs. */ public void waitForReadable() throws IOException { reader.waitForIO(SelectionKey.OP_READ); } }
public boolean isOpen() { return reader.isOpen(); }
public int read(ByteBuffer dst) throws IOException { return reader.doIO(dst, SelectionKey.OP_READ); }
public synchronized void close() throws IOException { /* * close the channel since Socket.getInputStream().close() * closes the socket. */ reader.channel.close(); reader.close(); }