Package org.apache.commons.net.telnet
Class TelnetInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- java.io.BufferedInputStream
-
- org.apache.commons.net.telnet.TelnetInputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Runnable
final class TelnetInputStream extends java.io.BufferedInputStream implements java.lang.Runnable
-
-
Field Summary
Fields Modifier and Type Field Description private int
bytesAvailable
private TelnetClient
client
private static int
EOF
End of file has been reachedprivate boolean
hasReachedEOF
private java.io.IOException
ioException
private boolean
isClosed
private int[]
queue
private int
queueHead
private int
queueTail
private boolean
readIsWaiting
private int
receiveState
(package private) static int
STATE_CR
(package private) static int
STATE_DATA
(package private) static int
STATE_DO
(package private) static int
STATE_DONT
(package private) static int
STATE_IAC
(package private) static int
STATE_IAC_SB
(package private) static int
STATE_SB
(package private) static int
STATE_SE
(package private) static int
STATE_WILL
(package private) static int
STATE_WONT
private int[]
suboption
private int
suboptionCount
private java.lang.Thread
thread
private boolean
threaded
private static int
WOULD_BLOCK
Read would block
-
Constructor Summary
Constructors Constructor Description TelnetInputStream(java.io.InputStream input, TelnetClient client)
TelnetInputStream(java.io.InputStream input, TelnetClient client, boolean readerThread)
-
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)
Gets 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()
-
-
-
Field Detail
-
EOF
private static final int EOF
End of file has been reached- See Also:
- Constant Field Values
-
WOULD_BLOCK
private static final int WOULD_BLOCK
Read would block- See Also:
- Constant Field Values
-
STATE_DATA
static final int STATE_DATA
- See Also:
- Constant Field Values
-
STATE_IAC
static final int STATE_IAC
- See Also:
- Constant Field Values
-
STATE_WILL
static final int STATE_WILL
- See Also:
- Constant Field Values
-
STATE_WONT
static final int STATE_WONT
- See Also:
- Constant Field Values
-
STATE_DO
static final int STATE_DO
- See Also:
- Constant Field Values
-
STATE_DONT
static final int STATE_DONT
- See Also:
- Constant Field Values
-
STATE_SB
static final int STATE_SB
- See Also:
- Constant Field Values
-
STATE_SE
static final int STATE_SE
- See Also:
- Constant Field Values
-
STATE_CR
static final int STATE_CR
- See Also:
- Constant Field Values
-
STATE_IAC_SB
static final int STATE_IAC_SB
- See Also:
- Constant Field Values
-
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 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)
-
TelnetInputStream
TelnetInputStream(java.io.InputStream input, TelnetClient client, boolean readerThread)
-
-
Method Detail
-
available
public int available() throws java.io.IOException
- Overrides:
available
in classjava.io.BufferedInputStream
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.BufferedInputStream
- Throws:
java.io.IOException
-
markSupported
public boolean markSupported()
Returns false. Mark is not supported.- Overrides:
markSupported
in classjava.io.BufferedInputStream
-
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 classjava.io.BufferedInputStream
- Throws:
java.io.IOException
-
read
private int read(boolean mayBlock) throws java.io.IOException
Gets 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
-
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 classjava.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 classjava.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.
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
start
void start()
-
-