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 boolean
private IOException
private boolean
private final int[]
private int
private int
private boolean
private int
private final int[]
private int
private final Thread
private boolean
(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 static final int
End of file has been reachedprivate 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 TypeMethodDescriptionprivate boolean
__processChar
(int ch) private int
__read
(boolean mayBlock) Get the next byte of data.(package private) void
_start()
int
void
close()
boolean
Returns false.int
read()
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()
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 -
__suboption_count
private int __suboption_count -
__threaded
private volatile boolean __threaded
-
-
Constructor Details
-
TelnetInputStream
TelnetInputStream(InputStream input, TelnetClient client, boolean readerThread) -
TelnetInputStream
TelnetInputStream(InputStream input, TelnetClient client)
-
-
Method Details
-
_start
void _start() -
__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
-
__processChar
- Throws:
InterruptedException
-
read
- Overrides:
read
in classBufferedInputStream
- 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.
-
markSupported
public boolean markSupported()Returns false. Mark is not supported.- Overrides:
markSupported
in classBufferedInputStream
-
available
- Overrides:
available
in classBufferedInputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classBufferedInputStream
- Throws:
IOException
-
run
public void run()
-