net.i2p.util

## Class TimeoutPipedInputStream

- java.lang.Object
- - java.io.InputStream
  - - java.io.PipedInputStream
    - - net.i2p.util.TimeoutPipedInputStream

- All Implemented Interfaces:
    Closeable, AutoCloseable

      class TimeoutPipedInputStream
      extends PipedInputStream

  Adds setReadTimeout(). Must be used with a TimeoutPipedOutputStream. To support InternalSocket.setSoTimeout(). Package private, not a part of the public API, not for general use.

- - ### Field Summary

    - ### Fields inherited from class java.io.PipedInputStream

      `buffer, in, out, PIPE_SIZE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TimeoutPipedInputStream(int pipeSize)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Overridden to save state.
    `int` | `read()`
    `void` | `setReadTimeout(int ms)` Must be called before blocking read call.
    `(package private) void` | `x_receivedLast()` To save state.

    - ### Methods inherited from class java.io.PipedInputStream

      `available, connect, read, receive`

    - ### Methods inherited from class java.io.InputStream

      `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

    - #### TimeoutPipedInputStream

          public TimeoutPipedInputStream(int pipeSize)

  - ### Method Detail

    - #### close

          public void close()
                     throws IOException

      Overridden to save state. We have to do this because can't get to closedByReader in super
      Specified by:
        `close` in interface `Closeable`
      Specified by:
        `close` in interface `AutoCloseable`
      Overrides:
        `close` in class `PipedInputStream`
      Throws:
        `IOException`

    - #### read

          public int read()
                   throws IOException

      Overrides:
        `read` in class `PipedInputStream`
      Throws:
        `SocketTimeoutException` - if timeout is reached
        `IOException`

    - #### setReadTimeout

          public void setReadTimeout(int ms)

      Must be called before blocking read call.
      Parameters:
        `ms` - less than or equal to zero means forever

    - #### x_receivedLast

          void x_receivedLast()

      To save state. We have to do this because can't get to closedByWriter in super.