|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.InputStream java.io.FilterInputStream org.sadun.util.TelnetInputStream
A stream to handle telnet-based communication.
The stream recognizes the standard TELNET command sequences (RFC854) in an input stream and allows for either batch or immediate handling.
Batch handling can be realized by retrieving the list of
commands
when the input is blocked, by
using getCommands()
.
Immediate handling can be realized by registering a
TelnetInputStream.TelnetCommandListener
and responding to the command
(to the appropriate output stream) with the result, and invoking
#commandHandled(TelnetCommand)
after the command has been properly handled.
TelnetInputStream.BasicNVTListener
is a listener which automatically
denies any option request, limiting the interaction capabilities to the
Telnet NVT.
See also the class TelnetInputStreamConsumer
for a
wrapper which provides efficient consumption capabilities for machine-processing
TELNET conversations.
Nested Class Summary | |
static class |
TelnetInputStream.BasicNVTListener
A standard TelnetInputStream.TelnetCommandListener that refuses
any option and suggestions, limiting the functionality to the basic
Telnet NVT (network virtual terminal) functionality. |
class |
TelnetInputStream.TelnetCommand
A Telnet command, associated to a specific TelnetInputStream .
|
static interface |
TelnetInputStream.TelnetCommandListener
A listener to Telnet commands. |
Field Summary | |
static int |
AO
The Telnet command code AO (245) |
static int |
AYT
The Telnet command code IAC (246) |
static int |
BREAK
The Telnet command code BREAK (243) |
static int |
DM
The Telnet command code DM (242) |
static int |
DO
The Telnet command code DO (253) |
static int |
DONT
The Telnet command code DONT (254) |
static int |
EC
The Telnet command code EC (247) |
static int |
EL
The Telnet command code EL (248) |
static int |
GA
The Telnet command code GA (249) |
static int |
IAC
The Telnet command code IAC (255) |
static int |
IP
The Telnet command code IP (244) |
static int |
NOP
The Telnet command code NOP (241) |
static int |
SB
The Telnet command code SB (250) |
static int |
SE
The Telnet command code SE (240) |
static int |
WILL
The Telnet command code WILL (251) |
static int |
WONT
The Telnet command code WONT (252) |
Fields inherited from class java.io.FilterInputStream |
in |
Constructor Summary | |
TelnetInputStream(java.io.InputStream in)
Create a telnet input stream over the given input stream. |
Method Summary | |
void |
commandHandled(TelnetInputStream.TelnetCommand command)
Remove a command from the list of unhandled commands. |
TelnetInputStream.TelnetCommand[] |
getCommands()
Return the list of commands encountered so far, and not yet handled. |
java.io.PrintStream |
getDebugStream()
A Line mode helper. |
int |
read()
|
void |
registerTelnetCommandListener(TelnetInputStream.TelnetCommandListener tcl)
Register a listener to Telnet commands. |
void |
removeTelnetCommandListener(TelnetInputStream.TelnetCommandListener tcl)
Remove a listener to Telnet commands. |
void |
setDebugStream(java.io.PrintStream debugStream)
|
Methods inherited from class java.io.FilterInputStream |
available, close, mark, markSupported, read, read, reset, skip |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int IAC
public static final int SE
public static final int NOP
public static final int DM
public static final int BREAK
public static final int IP
public static final int AO
public static final int AYT
public static final int EC
public static final int EL
public static final int GA
public static final int SB
public static final int WILL
public static final int WONT
public static final int DO
public static final int DONT
Constructor Detail |
public TelnetInputStream(java.io.InputStream in)
Method Detail |
public int read() throws java.io.IOException
java.io.IOException
public TelnetInputStream.TelnetCommand[] getCommands()
#commandHandled(TelnetCommand)
.
public void commandHandled(TelnetInputStream.TelnetCommand command)
command
- the command that has been handled.public void registerTelnetCommandListener(TelnetInputStream.TelnetCommandListener tcl)
tcl
- the listener to registerpublic void removeTelnetCommandListener(TelnetInputStream.TelnetCommandListener tcl)
tcl
- the listener to removepublic java.io.PrintStream getDebugStream()
java.io.IOException
- public String readLine() throws IOException {
StringBuffer sb = null;
int c0 = -1, c1 = -1;
while ((c1 = read()) != -1) {
if (sb == null)
sb = new StringBuffer();
if ((c0 == '\r' && c1 == '\n') | // CRLF|
(c0 == '\r' && c1 == 0)) // CR NUL
break;
sb.append((char) (c0 = c1));
}
if (sb == null)
return null;
sb.deleteCharAt(sb.length() - 1);
String result = sb.toString();
if (trimLinesEnabled)
result = result.trim();
return result;
}
/**
Return whether or not the line mode helper #readLine()
will trim
received lines.public void setDebugStream(java.io.PrintStream debugStream)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |