Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## jcontrol.net
Class SocketInputStream

    java.lang.Object
      jcontrol.net.SocketInputStream

All Implemented Interfaces:
  BasicInputStream

    public class SocketInputStream

extends Object
implements BasicInputStream

JControl Implementation of a SocketInputStream

Constructor Summary
`protected` | `SocketInputStream(Socket socket)` Constructor should only be initiated by the socket-class

Method Summary
`int` | `available()` not implemented for network streams
`void` | `close()` Closes this input stream and releases any system resources associated with the stream.
`protected void` | `finalize()` Free internal data structures used by this socketinputstream object.
`void` | `mark(int readlimit)` NOTE: not supported!
`boolean` | `markSupported()` NOTE: not supported!
`int` | `read()` Reads the next byte of data from the input stream.
`int` | `read(byte[] b)` Reads some number of bytes from the input stream and stores them into the buffer array `b`.
`int` | `read(byte[] buffer, int offset, int length)` Reads up to len bytes of data from the input stream into an array of bytes.
`void` | `reset()` NOTE: not supported!
`int` | `skip(int n)` not implemented for network streams

Methods inherited from class java.lang.Object
`clone, equals, getClass, notifyAll, toString, wait`

Constructor Detail

### SocketInputStream

    protected SocketInputStream(Socket socket)

  Constructor should only be initiated by the socket-class

  Parameters:
    `socket` -

Method Detail

### read

    public int read()
             throws IOException

  Reads the next byte of data from the input stream. The value byte is returned as an char in the range 0 to 255. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

  Specified by:
    `read` in interface `BasicInputStream`
  Returns:
    the next byte of data
  Throws:
    `IOException` - - if an I/O error occurs.

### read

    public int read(byte[] b)
             throws IOException

  Description copied from interface: `BasicInputStream`
  Reads some number of bytes from the input stream and stores them into the buffer array `b`. The number of bytes actually read is returned as an integer. This method blocks until input data is available, end of file is detected, or an exception is thrown.

  If `b` is `null`, a `NullPointerException` is thrown. If the length of `b` is zero, then no bytes are read and `0` is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at end of file, the value `-1` is returned; otherwise, at least one byte is read and stored into `b`.

  The first byte read is stored into element `b[0]`, the next one into `b[1]`, and so on. The number of bytes read is, at most, equal to the length of `b`. Let k be the number of bytes actually read; these bytes will be stored in elements `b[0]` through `b[`k`-1]`, leaving elements `b[`k`]` through `b[b.length-1]` unaffected.

  If the first byte cannot be read for any reason other than end of file, then an `IOException` is thrown. In particular, an `IOException` is thrown if the input stream has been closed.

  The `read(b)` method for class `InputStream` has the same effect as:

       read(b, 0, b.length)

  Specified by:
    `read` in interface `BasicInputStream`
  Parameters:
    `b` - the buffer into which the data is read.
  Returns:
    the total number of bytes read into the buffer, or `-1` is there is no more data because the end of the stream has been reached.
  Throws:
    `IOException` - if an I/O error occurs.
  See Also:
    `read(byte[] buffer, int offset, int length)`

### read

    public int read(byte[] buffer,
                    int offset,
                    int length)
             throws IOException

  Reads up to len bytes of data from the input stream into an array of bytes. An attempt is made to read as many as len bytes, but a smaller number may be read, possibly zero. The number of bytes actually read is returned as an integer. This method blocks until input data is available, end of file is detected, or an exception is thrown. If b is null, a NullPointerException is thrown. If off is negative, or len is negative, or off+len is greater than the length of the array b, then an IndexOutOfBoundsException is thrown. The first byte read is stored into element b[off], the next one into b[off+1], and so on. The number of bytes read is, at most, equal to len. Let k be the number of bytes actually read; these bytes will be stored in elements b[off] through b[off+k-1], leaving elements b[off+k] through b[off+len-1] unaffected.In every case, elements b[0] through b[off] and elements b[off+len] through b[b.length-1] are unaffected. If the first byte cannot be read for any reason other than end of file, then an IOException is thrown. In particular, an IOException is thrown if the input stream has been closed.

  Specified by:
    `read` in interface `BasicInputStream`
  Parameters:
    `buffer` - - the buffer into which the data is read.
    `offset` - - the start offset in array b at which the data is written.
    `length` - - the maximum number of bytes to read.
  Returns:
    the total number of bytes read into the buffer
  Throws:
    `IOException` - - if an I/O error occurs.
    `NullPointerException` - - if buffer is null.
  See Also:
    `InputStream.read()`

### close

    public void close()
               throws IOException

  Closes this input stream and releases any system resources associated with the stream.

  Specified by:
    `close` in interface `BasicInputStream`
  Throws:
    `IOException` - - if an I/O error occurs.

### available

    public int available()
                  throws IOException

  not implemented for network streams

  Specified by:
    `available` in interface `BasicInputStream`
  Returns:
    the number of bytes that can be read from this input stream without blocking.
  Throws:
    `IOException` - if an I/O error occurs.

### skip

    public int skip(int n)
             throws IOException

  not implemented for network streams

  Specified by:
    `skip` in interface `BasicInputStream`
  Parameters:
    `n` - the number of bytes to be skipped.
  Returns:
    the actual number of bytes skipped.
  Throws:
    `IOException` - if an I/O error occurs.

### finalize

    protected void finalize()

  Free internal data structures used by this socketinputstream object.

### mark

    public void mark(int readlimit)

  NOTE: not supported!

  Specified by:
    `mark` in interface `BasicInputStream`
  Parameters:
    `readlimit` - the maximum limit of bytes that can be read before the mark position becomes invalid.

### markSupported

    public boolean markSupported()

  NOTE: not supported!

  Specified by:
    `markSupported` in interface `BasicInputStream`
  Returns:
    `true` if this stream instance supports the mark and reset methods; `false` otherwise.

### reset

    public void reset()
               throws IOException

  NOTE: not supported!

  Specified by:
    `reset` in interface `BasicInputStream`
  Throws:
    `IOException` - if this stream has not been makred or if the mark has been invalidated.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD