public class TelnetIO extends Object
Although supposed to work full-duplex, we only process the telnet protocol layer communication in case of reading requests from the higher levels. This is the only way to meet the one thread per connection requirement.
The output is done via byte-oriented streams, definately suitable for the telnet protocol. The format of the output is UTF-8 (Unicode), which is a standard and supported by any telnet client, including the ones included in Microsoft OS's.
Notes:Modifier and Type | Field | Description |
---|---|---|
protected static int |
AO |
Abort Output
|
protected static int |
AUTHENTICATION |
|
protected static int |
AYT |
Are You There
|
protected static int |
BRK |
Break
|
protected static int |
DM |
Data mark its the data part of a SYNCH which helps to clean up the buffers between
Telnet Server <-> Telnet Client.
|
protected static int |
DO |
Negotiation: Do option
|
protected static int |
DONT |
Negotiation: Dont do option
|
protected static int |
EC |
Erase Char
|
protected static int |
ECHO |
Telnet Option: ECHO
|
protected static int |
EL |
Erase Line
|
protected static int |
ENCRYPT |
|
protected static int |
EXT_ASCII |
Unused
|
protected static int |
GA |
Go Ahead
Newer Telnets do not make use of this option that allows a specific communication mode. |
protected static int |
IAC |
Interpret As Command
|
protected static int |
IP |
Interrupt Process
|
protected static int |
IS |
TTYPE subnegotiation: IS
|
protected static int |
LINEMODE |
Telnet Option: Linemode
|
protected static int |
LM_EDIT |
|
protected static int |
LM_FORWARDMASK |
|
protected static int |
LM_MODE |
|
protected static int |
LM_MODEACK |
Following methods implement init/request/answer procedures for telnet
protocol level communication.
|
protected static int |
LM_SLC |
|
protected static int |
LM_SLC_ABORT |
The following implement the NVT (network virtual terminal) which offers the concept
of a simple "printer".
|
protected static int |
LM_SLC_ACK |
|
protected static int |
LM_SLC_AO |
|
protected static int |
LM_SLC_AYT |
|
protected static int |
LM_SLC_BRK |
|
protected static int |
LM_SLC_CANTCHANGE |
Constants declaration
|
protected static int |
LM_SLC_DEFAULT |
|
protected static int |
LM_SLC_EOF |
|
protected static int |
LM_SLC_EOR |
|
protected static int |
LM_SLC_FLUSHIN |
|
protected static int |
LM_SLC_FLUSHOUT |
|
protected static int |
LM_SLC_IP |
|
protected static int |
LM_SLC_LEVELBITS |
|
protected static int |
LM_SLC_NOSUPPORT |
|
protected static int |
LM_SLC_SUSP |
|
protected static int |
LM_SLC_SYNCH |
|
protected static int |
LM_SLC_VALUE |
End telnet protocol level communication methods
|
protected static int |
LM_TRAPSIG |
|
protected static int |
LOGOUT |
Telnet Option: Logout
This allows nice goodbye to time-outed or unwanted clients. |
protected static int |
NAWS |
Telnet Option: Negotiate About Window Size
Server request is IAC DO NAWS Client response contains subnegotiation with data (columns, rows). |
protected static int |
NE_ESC |
The following options are options for which we also support subnegotiation
based upon the telnet protocol specification.
|
protected static int |
NE_IN_END |
|
protected static int |
NE_IN_ERROR |
|
protected static int |
NE_INFO |
|
protected static int |
NE_USERVAR |
|
protected static int |
NE_VALUE |
|
protected static int |
NE_VAR |
The following are constants for supported options,
which can be negotiated based upon the telnet protocol
specification.
|
protected static int |
NE_VAR_DEFINED |
|
protected static int |
NE_VAR_DEFINED_EMPTY |
|
protected static int |
NE_VAR_NAME_MAXLENGTH |
|
protected static int |
NE_VAR_OK |
|
protected static int |
NE_VAR_UNDEFINED |
|
protected static int |
NE_VAR_VALUE_MAXLENGTH |
|
protected static int |
NEWENV |
Telnet Option: Environment
|
protected static int |
NOP |
No operation
|
protected static int |
SB |
Marks start of a subnegotiation.
|
protected static int |
SE |
Marks end of subnegotiation.
|
protected static int |
SEND |
TTYPE subnegotiation: SEND
|
protected static int |
SEND_LOC |
|
protected static int |
SUPGA |
Telnet Option: SUPress Go Ahead
This will be negotiated, all new telnet protocol implementations are recommended to do this. |
protected static int |
TTYPE |
Telnet Option: Terminal TYPE
Server request contains subnegotiation SEND Client response contains subnegotiation with data IS,terminal type string |
protected static int |
WILL |
Negotiation: Will do option
|
protected static int |
WONT |
Negotiation: Wont do option
|
Constructor | Description |
---|---|
TelnetIO() |
Creates a TelnetIO object for the given connection.
Input- and OutputStreams are properly set and the primary telnet protocol initialization is carried out by the inner IACHandler class. |
Modifier and Type | Method | Description |
---|---|---|
void |
closeInput() |
Method to close the underlying inputstream to free system resources.
Most likely only to be called by the ConnectionManager upon clean up of connections that ended or died. |
void |
closeOutput() |
Method to close the underlying output stream to free system resources.
Most likely only to be called by the ConnectionManager upon clean up of connections that ended or died. |
void |
flush() |
Method to flush all buffered output.
|
void |
initIO() |
|
int |
read() |
Method to read a byte from the InputStream.
|
void |
setConnection(Connection con) |
|
void |
setEcho(boolean b) |
|
void |
write(byte b) |
Method to output a byte.
|
void |
write(byte[] sequence) |
Method to write an array of bytes.
|
void |
write(char ch) |
Method to write a char.
|
void |
write(int i) |
Method to output an int.
|
void |
write(int[] sequence) |
Method to output an array of int' s.
|
void |
write(String str) |
Method to output a string.
|
protected static final int IAC
protected static final int GA
protected static final int WILL
protected static final int WONT
protected static final int DO
protected static final int DONT
protected static final int SB
protected static final int SE
protected static final int NOP
protected static final int DM
protected static final int BRK
protected static final int IP
protected static final int AO
protected static final int AYT
protected static final int EC
protected static final int EL
protected static final int ECHO
protected static final int SUPGA
protected static final int NAWS
protected static final int TTYPE
protected static final int IS
protected static final int SEND
protected static final int LOGOUT
protected static final int LINEMODE
The infamous line mode option.
protected static final int LM_MODE
protected static final int LM_EDIT
protected static final int LM_TRAPSIG
protected static final int LM_MODEACK
protected static final int LM_FORWARDMASK
protected static final int LM_SLC
protected static final int LM_SLC_NOSUPPORT
protected static final int LM_SLC_DEFAULT
protected static final int LM_SLC_VALUE
protected static final int LM_SLC_CANTCHANGE
protected static final int LM_SLC_LEVELBITS
protected static final int LM_SLC_ACK
protected static final int LM_SLC_FLUSHIN
protected static final int LM_SLC_FLUSHOUT
protected static final int LM_SLC_SYNCH
protected static final int LM_SLC_BRK
protected static final int LM_SLC_IP
protected static final int LM_SLC_AO
protected static final int LM_SLC_AYT
protected static final int LM_SLC_EOR
protected static final int LM_SLC_ABORT
protected static final int LM_SLC_EOF
protected static final int LM_SLC_SUSP
protected static final int NEWENV
protected static final int NE_INFO
protected static final int NE_VAR
protected static final int NE_VALUE
protected static final int NE_ESC
protected static final int NE_USERVAR
protected static final int NE_VAR_OK
protected static final int NE_VAR_DEFINED
protected static final int NE_VAR_DEFINED_EMPTY
protected static final int NE_VAR_UNDEFINED
protected static final int NE_IN_ERROR
protected static final int NE_IN_END
protected static final int NE_VAR_NAME_MAXLENGTH
protected static final int NE_VAR_VALUE_MAXLENGTH
protected static final int EXT_ASCII
protected static final int SEND_LOC
protected static final int AUTHENTICATION
protected static final int ENCRYPT
public TelnetIO()
public void initIO() throws IOException
IOException
public void setConnection(Connection con)
public void write(byte b) throws IOException
b
- Byte to be written.IOException
- if an error occurspublic void write(int i) throws IOException
i
- Integer to be written.IOException
- if an error occurspublic void write(byte[] sequence) throws IOException
sequence
- byte[] to be written.IOException
- if an error occurspublic void write(int[] sequence) throws IOException
sequence
- int [] to writeIOException
- if an error occurspublic void write(char ch) throws IOException
ch
- char to be written.IOException
- if an error occurspublic void write(String str) throws IOException
str
- String to be written.IOException
- if an error occurspublic void flush() throws IOException
IOException
- if an error occurspublic void closeOutput()
public int read() throws IOException
IOException
- if an error occurspublic void closeInput()
public void setEcho(boolean b)
Copyright © 2020. All rights reserved.