Class TelnetInputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.lang.Runnable

    final class TelnetInputStream
    extends java.io.BufferedInputStream
    implements java.lang.Runnable
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int available()  
      void close()  
      boolean markSupported()
      Returns false.
      private boolean processChar​(int ch)  
      int read()  
      private int read​(boolean mayBlock)
      Get the next byte of data.
      int read​(byte[] buffer)
      Reads the next number of bytes from the stream into an array and returns the number of bytes read.
      int read​(byte[] buffer, int offset, int length)
      Reads the next number of bytes from the stream into an array and returns the number of bytes read.
      void run()  
      (package private) void start()  
      • Methods inherited from class java.io.BufferedInputStream

        mark, reset, skip
      • Methods inherited from class java.io.InputStream

        nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • 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
      • thread

        private final java.lang.Thread thread
      • ioException

        private java.io.IOException ioException
      • suboption

        private final int[] suboption
      • suboptionCount

        private int suboptionCount
      • threaded

        private volatile boolean threaded
    • Constructor Detail

      • TelnetInputStream

        TelnetInputStream​(java.io.InputStream input,
                          TelnetClient client,
                          boolean readerThread)
      • TelnetInputStream

        TelnetInputStream​(java.io.InputStream input,
                          TelnetClient client)
    • Method Detail

      • start

        void start()
      • read

        private int read​(boolean mayBlock)
                  throws java.io.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:
        java.io.IOException
      • processChar

        private boolean processChar​(int ch)
                             throws java.lang.InterruptedException
        Throws:
        java.lang.InterruptedException
      • read

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

        public int read​(byte[] buffer)
                 throws java.io.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 java.io.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:
        java.io.IOException - If an error occurs in reading the underlying stream.
      • read

        public int read​(byte[] buffer,
                        int offset,
                        int length)
                 throws java.io.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 java.io.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:
        java.io.IOException - If an error occurs while reading the underlying stream.
      • markSupported

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

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

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.BufferedInputStream
        Throws:
        java.io.IOException
      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable