seda.nbio
Class NonblockingSocketInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by seda.nbio.NonblockingInputStream
          extended by seda.nbio.NonblockingSocketInputStream
All Implemented Interfaces:
java.io.Closeable

 class NonblockingSocketInputStream
extends NonblockingInputStream

Package-internal class implementing NonblockingInputStream for nonblocking sockets.


Constructor Summary
NonblockingSocketInputStream(NonblockingSocketImpl impl)
           
 
Method Summary
 int available()
           
 void close()
           
 int nbRead()
          Perform a non-blocking read of one byte from this input stream.
 int read()
          Perform a blocking read of one byte from this input stream.
 int read(byte[] b)
          Perform a non-blocking read of up to b.length bytes from the underlying stream.
 int read(byte[] b, int off, int len)
          Perform a non-blocking read of up to len bytes from the underlying stream into the byte array b starting at offset off.
 long skip(long n)
          Skip n bytes of input.
 
Methods inherited from class java.io.InputStream
mark, markSupported, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NonblockingSocketInputStream

NonblockingSocketInputStream(NonblockingSocketImpl impl)
Method Detail

read

public int read()
         throws java.io.IOException
Perform a blocking read of one byte from this input stream. Returns -1 if the end of the stream has been reached. Use nbRead() to perform a non-blocking read of one byte.

Specified by:
read in class NonblockingInputStream
Throws:
java.io.IOException

nbRead

public int nbRead()
           throws java.io.IOException
Perform a non-blocking read of one byte from this input stream. Returns -1 if no data is available, or throws an EOFException if the end of the stream has been reached. Use read() to perform a blocking read of one byte.

Specified by:
nbRead in class NonblockingInputStream
Throws:
java.io.IOException

read

public int read(byte[] b)
         throws java.io.IOException
Perform a non-blocking read of up to b.length bytes from the underlying stream.

Specified by:
read in class NonblockingInputStream
Returns:
The total number of bytes read into the buffer, 0 if no data was available, or -1 if the end of the stream has been reached.
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Perform a non-blocking read of up to len bytes from the underlying stream into the byte array b starting at offset off.

Specified by:
read in class NonblockingInputStream
Returns:
The total number of bytes read into the buffer, 0 if no data was available, or -1 if the end of the stream has been reached.
Throws:
java.io.IOException

skip

public long skip(long n)
          throws java.io.IOException
Skip n bytes of input. This is a blocking operation.

Specified by:
skip in class NonblockingInputStream
Throws:
java.io.IOException

available

public int available()
              throws java.io.IOException
Specified by:
available in class NonblockingInputStream
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Specified by:
close in class NonblockingInputStream
Throws:
java.io.IOException