Class TelnetInputStream

All Implemented Interfaces:
Closeable, AutoCloseable, Runnable

final class TelnetInputStream extends BufferedInputStream implements Runnable
  • Field Details

    • EOF

      private static final int EOF
      End of file has been reached
      See Also:
    • WOULD_BLOCK

      private static final int WOULD_BLOCK
      Read would block
      See Also:
    • STATE_DATA

      static final int STATE_DATA
      See Also:
    • STATE_IAC

      static final int STATE_IAC
      See Also:
    • STATE_WILL

      static final int STATE_WILL
      See Also:
    • STATE_WONT

      static final int STATE_WONT
      See Also:
    • STATE_DO

      static final int STATE_DO
      See Also:
    • STATE_DONT

      static final int STATE_DONT
      See Also:
    • STATE_SB

      static final int STATE_SB
      See Also:
    • STATE_SE

      static final int STATE_SE
      See Also:
    • STATE_CR

      static final int STATE_CR
      See Also:
    • STATE_IAC_SB

      static final int STATE_IAC_SB
      See Also:
    • hasReachedEOF

      private boolean hasReachedEOF
    • isClosed

      private volatile boolean isClosed
    • readIsWaiting

      private boolean readIsWaiting
    • receiveState

      private int receiveState
    • queueHead

      private int queueHead
    • queueTail

      private int queueTail
    • bytesAvailable

      private int bytesAvailable
    • queue

      private final int[] queue
    • client

      private final TelnetClient client
    • thread

      private final Thread thread
    • ioException

      private IOException ioException
    • suboption

      private final int[] suboption
    • suboptionCount

      private int suboptionCount
    • threaded

      private volatile boolean threaded
  • Constructor Details

  • Method Details

    • available

      public int available() throws IOException
      Overrides:
      available in class BufferedInputStream
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class BufferedInputStream
      Throws:
      IOException
    • markSupported

      public boolean markSupported()
      Returns false. Mark is not supported.
      Overrides:
      markSupported in class BufferedInputStream
    • processChar

      private boolean processChar(int ch) throws InterruptedException
      Throws:
      InterruptedException
    • read

      public int read() throws IOException
      Overrides:
      read in class BufferedInputStream
      Throws:
      IOException
    • read

      private int read(boolean mayBlock) throws IOException
      Get the next byte of data. IAC commands are processed internally and do not return data.
      Parameters:
      mayBlock - true if method is allowed to block
      Returns:
      the next byte of data, or -1 (EOF) if end of stread reached, or -2 (WOULD_BLOCK) if mayBlock is false and there is no data available
      Throws:
      IOException
    • read

      public int read(byte[] buffer) throws IOException
      Reads the next number of bytes from the stream into an array and returns the number of bytes read. Returns -1 if the end of the stream has been reached.

      Overrides:
      read in class FilterInputStream
      Parameters:
      buffer - The byte array in which to store the data.
      Returns:
      The number of bytes read. Returns -1 if the end of the message has been reached.
      Throws:
      IOException - If an error occurs in reading the underlying stream.
    • read

      public int read(byte[] buffer, int offset, int length) throws IOException
      Reads the next number of bytes from the stream into an array and returns the number of bytes read. Returns -1 if the end of the message has been reached. The characters are stored in the array starting from the given offset and up to the length specified.

      Overrides:
      read in class BufferedInputStream
      Parameters:
      buffer - The byte array in which to store the data.
      offset - The offset into the array at which to start storing data.
      length - The number of bytes to read.
      Returns:
      The number of bytes read. Returns -1 if the end of the stream has been reached.
      Throws:
      IOException - If an error occurs while reading the underlying stream.
    • run

      public void run()
      Specified by:
      run in interface Runnable
    • start

      void start()