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:
Closeable
,AutoCloseable
,Runnable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
private final TelnetClient
private static final int
End of file has been reachedprivate boolean
private IOException
private boolean
private final int[]
private int
private int
private boolean
private int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
private final int[]
private int
private final Thread
private boolean
private static final int
Read would blockFields inherited from class java.io.FilterInputStream
in
-
Constructor Summary
ConstructorsConstructorDescriptionTelnetInputStream
(InputStream input, TelnetClient client) TelnetInputStream
(InputStream input, TelnetClient client, boolean readerThread) -
Method Summary
Modifier and TypeMethodDescriptionint
void
close()
boolean
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, skipNBytes, transferTo
-
Field Details
-
EOF
private static final int EOFEnd of file has been reached- See Also:
-
WOULD_BLOCK
private static final int WOULD_BLOCKRead 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
-
thread
-
ioException
-
suboption
private final int[] suboption -
suboptionCount
private int suboptionCount -
threaded
private volatile boolean threaded
-
-
Constructor Details
-
TelnetInputStream
TelnetInputStream(InputStream input, TelnetClient client) -
TelnetInputStream
TelnetInputStream(InputStream input, TelnetClient client, boolean readerThread)
-
-
Method Details
-
available
- Overrides:
available
in classBufferedInputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classBufferedInputStream
- Throws:
IOException
-
markSupported
public boolean markSupported()Returns false. Mark is not supported.- Overrides:
markSupported
in classBufferedInputStream
-
processChar
- Throws:
InterruptedException
-
read
- Overrides:
read
in classBufferedInputStream
- Throws:
IOException
-
read
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
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 classFilterInputStream
- 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
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 classBufferedInputStream
- 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() -
start
void start()
-