class Telnet extends SocketClient
| Modifier and Type | Field and Description |
|---|---|
(package private) static byte[] |
COMMAND_AYT
AYT sequence
|
(package private) static byte[] |
COMMAND_DO |
(package private) static byte[] |
COMMAND_DONT |
(package private) static byte[] |
COMMAND_IS
Is sequence (for subnegotiation)
|
(package private) static byte[] |
COMMAND_SB |
(package private) static byte[] |
COMMAND_SE |
(package private) static byte[] |
COMMAND_WILL |
(package private) static byte[] |
COMMAND_WONT |
(package private) static boolean |
debug |
(package private) static boolean |
debugoptions |
(package private) static int |
DEFAULT_PORT |
(package private) static int |
DO_MASK |
(package private) static char |
NUL |
(package private) static int |
REQUESTED_DO_MASK |
(package private) static int |
REQUESTED_WILL_MASK |
protected static int |
TERMINAL_TYPE
Terminal type option
|
protected static int |
TERMINAL_TYPE_IS
Is (for subnegotiation)
|
protected static int |
TERMINAL_TYPE_SEND
Send (for subnegotiation)
|
(package private) static int |
WILL_MASK |
_defaultPort_, _hostname_, _input_, _output_, _serverSocketFactory_, _socket_, _socketFactory_, _timeout_, connectTimeout, NETASCII_EOL, remoteInetSocketAddress| Constructor and Description |
|---|
Telnet()
Empty Constructor
|
Telnet(String termtype)
This constructor lets you specify the terminal type.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
_connectAction_()
Called upon connection.
|
(package private) void |
_registerSpyStream(OutputStream spystream)
Registers an OutputStream for spying what's going on in the Telnet session.
|
(package private) boolean |
_sendAYT(java.time.Duration timeout)
Sends an
Are You There (AYT) sequence and waits for the result. |
(package private) void |
_sendCommand(byte cmd)
Sends a command, automatically adds IAC prefix and flushes the output.
|
(package private) void |
_sendSubnegotiation(int[] subn)
Manages subnegotiation for Terminal Type.
|
(package private) void |
_stopSpyStream()
Stops spying this Telnet.
|
(package private) void |
addOptionHandler(TelnetOptionHandler opthand)
Registers a new TelnetOptionHandler for this Telnet to use.
|
(package private) void |
deleteOptionHandler(int optcode)
Unregisters a TelnetOptionHandler.
|
(package private) void |
processAYTResponse()
Processes the response of an AYT
|
(package private) void |
processCommand(int command)
Processes a COMMAND.
|
(package private) void |
processDo(int option)
Processes a
DO request. |
(package private) void |
processDont(int option)
Processes a
DONT request. |
(package private) void |
processSuboption(int[] suboption,
int suboptionLength)
Processes a suboption negotiation.
|
(package private) void |
processWill(int option)
Processes a
WILL request. |
(package private) void |
processWont(int option)
Processes a
WONT request. |
void |
registerNotifHandler(TelnetNotificationHandler notifhand)
Registers a notification handler to which will be sent notifications of received Telnet option negotiation commands.
|
(package private) void |
requestDo(int option)
Requests a DO.
|
(package private) void |
requestDont(int option)
Requests a
DONT. |
(package private) boolean |
requestedDo(int option)
Looks for the state of the option.
|
(package private) boolean |
requestedDont(int option)
Looks for the state of the option.
|
(package private) boolean |
requestedWill(int option)
Looks for the state of the option.
|
(package private) boolean |
requestedWont(int option)
Looks for the state of the option.
|
(package private) void |
requestWill(int option)
Requests a
WILL. |
(package private) void |
requestWont(int option)
Requests a
WONT. |
(package private) void |
sendByte(int b)
Sends a byte.
|
(package private) void |
sendDo(int option)
Sends a
DO. |
(package private) void |
sendDont(int option)
Sends a
DONT. |
(package private) void |
sendTerminalType()
Sends terminal type information.
|
(package private) void |
sendWill(int option)
Sends a
WILL. |
(package private) void |
sendWont(int option)
Sends a
WONT. |
(package private) void |
setDo(int option)
Sets the state of the option.
|
(package private) void |
setDont(int option)
Sets the state of the option.
|
(package private) void |
setWantDo(int option)
Sets the state of the option.
|
(package private) void |
setWantDont(int option)
Sets the state of the option.
|
(package private) void |
setWantWill(int option)
Sets the state of the option.
|
(package private) void |
setWantWont(int option)
Sets the state of the option.
|
(package private) void |
setWill(int option)
Sets the state of the option.
|
(package private) void |
setWont(int option)
Sets the state of the option.
|
(package private) void |
spyRead(int ch)
Sends a read char on the spy stream.
|
(package private) void |
spyWrite(int ch)
Sends a written char on the spy stream.
|
(package private) boolean |
stateIsDo(int option)
Looks for the state of the option.
|
(package private) boolean |
stateIsDont(int option)
Looks for the state of the option.
|
(package private) boolean |
stateIsWill(int option)
Looks for the state of the option.
|
(package private) boolean |
stateIsWont(int option)
Looks for the state of the option.
|
void |
unregisterNotifHandler()
Unregisters the current notification handler.
|
addProtocolCommandListener, applySocketAttributes, checkOpenOutputStream, connect, connect, connect, connect, connect, connect, createCommandSupport, disconnect, fireCommandSent, fireReplyReceived, getCharset, getCommandSupport, getConnectTimeout, getDefaultPort, getDefaultTimeout, getHostAddress, getHostAddress, getKeepAlive, getLocalAddress, getLocalPort, getProxy, getReceiveBufferSize, getRemoteAddress, getRemoteInetSocketAddress, getRemotePort, getSendBufferSize, getServerSocketFactory, getSoLinger, getSoTimeout, getTcpNoDelay, isAvailable, isConnected, removeProtocolCommandListener, setCharset, setConnectTimeout, setDefaultPort, setDefaultTimeout, setKeepAlive, setProxy, setReceiveBufferSize, setSendBufferSize, setServerSocketFactory, setSocketFactory, setSoLinger, setSoTimeout, setTcpNoDelay, verifyRemotestatic final byte[] COMMAND_AYT
static final byte[] COMMAND_DO
static final byte[] COMMAND_DONT
static final byte[] COMMAND_IS
static final byte[] COMMAND_SB
static final byte[] COMMAND_SE
static final byte[] COMMAND_WILL
static final byte[] COMMAND_WONT
static final boolean debug
static final boolean debugoptions
static final int DEFAULT_PORT
static final int DO_MASK
static final char NUL
static final int REQUESTED_DO_MASK
static final int REQUESTED_WILL_MASK
protected static final int TERMINAL_TYPE
protected static final int TERMINAL_TYPE_IS
protected static final int TERMINAL_TYPE_SEND
static final int WILL_MASK
Telnet()
Telnet(String termtype)
termtype - terminal type to be negotiated (ej. VT100)protected void _connectAction_()
throws IOException
_connectAction_ in class SocketClientIOException - - Exception in I/O.void _registerSpyStream(OutputStream spystream)
spystream - OutputStream on which session activity will be echoed.final boolean _sendAYT(java.time.Duration timeout)
throws IOException,
IllegalArgumentException,
InterruptedException
Are You There (AYT) sequence and waits for the result.timeout - Time to wait for a response.IOException - - Exception in I/O.IllegalArgumentException - - Illegal argumentInterruptedException - - Interrupted during wait.final void _sendCommand(byte cmd)
throws IOException
cmd - command data to be sentIOException - - Exception in I/O.final void _sendSubnegotiation(int[] subn)
throws IOException
subn - subnegotiation data to be sentIOException - - Exception in I/O.void _stopSpyStream()
void addOptionHandler(TelnetOptionHandler opthand) throws InvalidTelnetOptionException, IOException
opthand - option handler to be registered.InvalidTelnetOptionException - - The option code is invalid.IOException - on errorvoid deleteOptionHandler(int optcode)
throws InvalidTelnetOptionException,
IOException
optcode - Code of the option to be unregistered.InvalidTelnetOptionException - - The option code is invalid.IOException - on errorfinal void processAYTResponse()
void processCommand(int command)
command - option code to be set.void processDo(int option)
throws IOException
DO request.option - option code to be set.IOException - - Exception in I/O.void processDont(int option)
throws IOException
DONT request.option - option code to be set.IOException - - Exception in I/O.void processSuboption(int[] suboption,
int suboptionLength)
throws IOException
suboption - subnegotiation data receivedsuboptionLength - length of data receivedIOException - - Exception in I/O.void processWill(int option)
throws IOException
WILL request.option - option code to be set.IOException - - Exception in I/O.void processWont(int option)
throws IOException
WONT request.option - option code to be set.IOException - - Exception in I/O.public void registerNotifHandler(TelnetNotificationHandler notifhand)
notifhand - TelnetNotificationHandler to be registeredfinal void requestDo(int option)
throws IOException
option - Option code.IOException - - Exception in I/O.final void requestDont(int option)
throws IOException
DONT.option - Option code.IOException - - Exception in I/O.boolean requestedDo(int option)
option - option code to be looked up.DO has been requested.boolean requestedDont(int option)
option - option code to be looked up.DONT has been requestedboolean requestedWill(int option)
option - option code to be looked up.WILL has been requestedboolean requestedWont(int option)
option - option code to be looked up.WONT has been requestedfinal void requestWill(int option)
throws IOException
WILL.option - Option code.IOException - - Exception in I/O.final void requestWont(int option)
throws IOException
WONT.option - Option code.IOException - - Exception in I/O.final void sendByte(int b)
throws IOException
b - byte to sendIOException - - Exception in I/O.final void sendDo(int option)
throws IOException
DO.option - Option code.IOException - - Exception in I/O.final void sendDont(int option)
throws IOException
DONT.option - Option code.IOException - - Exception in I/O.final void sendTerminalType()
throws IOException
IOException - - Exception in I/O.final void sendWill(int option)
throws IOException
WILL.option - Option code.IOException - - Exception in I/O.final void sendWont(int option)
throws IOException
WONT.option - Option code.IOException - - Exception in I/O.void setDo(int option)
throws IOException
option - option code to be set.IOExceptionvoid setDont(int option)
option - option code to be set.void setWantDo(int option)
option - option code to be set.void setWantDont(int option)
option - option code to be set.void setWantWill(int option)
option - option code to be set.void setWantWont(int option)
option - option code to be set.void setWill(int option)
throws IOException
option - option code to be set.IOExceptionvoid setWont(int option)
option - option code to be set.void spyRead(int ch)
ch - character read from the sessionvoid spyWrite(int ch)
ch - character written to the sessionboolean stateIsDo(int option)
option - option code to be looked up.DO has been acknowledged.boolean stateIsDont(int option)
option - option code to be looked up.DONT has been acknowledgedboolean stateIsWill(int option)
option - option code to be looked up.WILL has been acknowledgedboolean stateIsWont(int option)
option - option code to be looked up.WONT has been acknowledgedpublic void unregisterNotifHandler()