|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.InputStream org.apache.hadoop.net.SocketInputStream
public class SocketInputStream
This implements an input stream that can have a timeout while reading.
This sets non-blocking flag on the socket channel.
So after create this object, read() on
Socket.getInputStream()
and write() on
Socket.getOutputStream()
for the associated socket will throw
IllegalBlockingModeException.
Please use SocketOutputStream
for writing.
Constructor Summary | |
---|---|
SocketInputStream(ReadableByteChannel channel,
long timeout)
Create a new input stream with the given timeout. |
|
SocketInputStream(Socket socket)
Same as SocketInputStream(socket.getChannel(), socket.getSoTimeout()) : Create a new input stream with the given timeout. |
|
SocketInputStream(Socket socket,
long timeout)
Same as SocketInputStream(socket.getChannel(), timeout): Create a new input stream with the given timeout. |
Method Summary | |
---|---|
void |
close()
|
ReadableByteChannel |
getChannel()
Returns underlying channel used by inputstream. |
boolean |
isOpen()
|
int |
read()
|
int |
read(byte[] b,
int off,
int len)
|
int |
read(ByteBuffer dst)
|
void |
waitForReadable()
waits for the underlying channel to be ready for reading. |
Methods inherited from class java.io.InputStream |
---|
available, mark, markSupported, read, reset, skip |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SocketInputStream(ReadableByteChannel channel, long timeout) throws IOException
channel
- Channel for reading, should also be a SelectableChannel
.
The channel will be configured to be non-blocking.timeout
- timeout in milliseconds. must not be negative.
IOException
public SocketInputStream(Socket socket, long timeout) throws IOException
socket
- should have a channel associated with it.timeout
- timeout timeout in milliseconds. must not be negative.
IOException
SocketInputStream(ReadableByteChannel, long)
public SocketInputStream(Socket socket) throws IOException
socket
- should have a channel associated with it.
IOException
SocketInputStream(ReadableByteChannel, long)
Method Detail |
---|
public int read() throws IOException
read
in class InputStream
IOException
public int read(byte[] b, int off, int len) throws IOException
read
in class InputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface Channel
close
in class InputStream
IOException
public ReadableByteChannel getChannel()
FileChannel.transferFrom(ReadableByteChannel, long, long)
.
public boolean isOpen()
isOpen
in interface Channel
public int read(ByteBuffer dst) throws IOException
read
in interface ReadableByteChannel
IOException
public void waitForReadable() throws IOException
SocketTimeoutException
- if select on the channel times out.
IOException
- if any other I/O error occurs.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |