Class Telnet

java.lang.Object
org.apache.commons.net.SocketClient
org.apache.commons.net.telnet.Telnet
Direct Known Subclasses:
TelnetClient

class Telnet extends SocketClient
  • Field Details

    • debug

      static final boolean debug
      See Also:
    • debugoptions

      static final boolean debugoptions
      See Also:
    • _COMMAND_DO

      static final byte[] _COMMAND_DO
    • _COMMAND_DONT

      static final byte[] _COMMAND_DONT
    • _COMMAND_WILL

      static final byte[] _COMMAND_WILL
    • _COMMAND_WONT

      static final byte[] _COMMAND_WONT
    • _COMMAND_SB

      static final byte[] _COMMAND_SB
    • _COMMAND_SE

      static final byte[] _COMMAND_SE
    • _WILL_MASK

      static final int _WILL_MASK
      See Also:
    • _DO_MASK

      static final int _DO_MASK
      See Also:
    • _REQUESTED_WILL_MASK

      static final int _REQUESTED_WILL_MASK
      See Also:
    • _REQUESTED_DO_MASK

      static final int _REQUESTED_DO_MASK
      See Also:
    • DEFAULT_PORT

      static final int DEFAULT_PORT
      See Also:
    • _doResponse

      int[] _doResponse
    • _willResponse

      int[] _willResponse
    • _options

      int[] _options
    • TERMINAL_TYPE

      protected static final int TERMINAL_TYPE
      Terminal type option
      See Also:
    • TERMINAL_TYPE_SEND

      protected static final int TERMINAL_TYPE_SEND
      Send (for subnegotiation)
      See Also:
    • TERMINAL_TYPE_IS

      protected static final int TERMINAL_TYPE_IS
      Is (for subnegotiation)
      See Also:
    • _COMMAND_IS

      static final byte[] _COMMAND_IS
      Is sequence (for subnegotiation)
    • terminalType

      private String terminalType
      Terminal type
    • optionHandlers

      private final TelnetOptionHandler[] optionHandlers
      Array of option handlers
    • _COMMAND_AYT

      static final byte[] _COMMAND_AYT
      AYT sequence
    • aytMonitor

      private final Object aytMonitor
      monitor to wait for AYT
    • aytFlag

      private volatile boolean aytFlag
      flag for AYT
    • spyStream

      private volatile OutputStream spyStream
      The stream on which to spy
    • __notifhand

      private TelnetNotificationHandler __notifhand
      The notification handler
  • Constructor Details

    • Telnet

      Telnet()
      Empty Constructor
    • Telnet

      Telnet(String termtype)
      This constructor lets you specify the terminal type.
      Parameters:
      termtype - - terminal type to be negotiated (ej. VT100)
  • Method Details

    • _stateIsWill

      boolean _stateIsWill(int option)
      Looks for the state of the option.
      Parameters:
      option - - option code to be looked up.
      Returns:
      returns true if a will has been acknowledged
    • _stateIsWont

      boolean _stateIsWont(int option)
      Looks for the state of the option.
      Parameters:
      option - - option code to be looked up.
      Returns:
      returns true if a wont has been acknowledged
    • _stateIsDo

      boolean _stateIsDo(int option)
      Looks for the state of the option.
      Parameters:
      option - - option code to be looked up.
      Returns:
      returns true if a do has been acknowledged
    • _stateIsDont

      boolean _stateIsDont(int option)
      Looks for the state of the option.
      Parameters:
      option - - option code to be looked up.
      Returns:
      returns true if a dont has been acknowledged
    • _requestedWill

      boolean _requestedWill(int option)
      Looks for the state of the option.
      Parameters:
      option - - option code to be looked up.
      Returns:
      returns true if a will has been reuqested
    • _requestedWont

      boolean _requestedWont(int option)
      Looks for the state of the option.
      Parameters:
      option - - option code to be looked up.
      Returns:
      returns true if a wont has been reuqested
    • _requestedDo

      boolean _requestedDo(int option)
      Looks for the state of the option.
      Parameters:
      option - - option code to be looked up.
      Returns:
      returns true if a do has been reuqested
    • _requestedDont

      boolean _requestedDont(int option)
      Looks for the state of the option.
      Parameters:
      option - - option code to be looked up.
      Returns:
      returns true if a dont has been reuqested
    • _setWill

      void _setWill(int option) throws IOException
      Sets the state of the option.
      Parameters:
      option - - option code to be set.
      Throws:
      IOException
    • _setDo

      void _setDo(int option) throws IOException
      Sets the state of the option.
      Parameters:
      option - - option code to be set.
      Throws:
      IOException
    • _setWantWill

      void _setWantWill(int option)
      Sets the state of the option.
      Parameters:
      option - - option code to be set.
    • _setWantDo

      void _setWantDo(int option)
      Sets the state of the option.
      Parameters:
      option - - option code to be set.
    • _setWont

      void _setWont(int option)
      Sets the state of the option.
      Parameters:
      option - - option code to be set.
    • _setDont

      void _setDont(int option)
      Sets the state of the option.
      Parameters:
      option - - option code to be set.
    • _setWantWont

      void _setWantWont(int option)
      Sets the state of the option.
      Parameters:
      option - - option code to be set.
    • _setWantDont

      void _setWantDont(int option)
      Sets the state of the option.
      Parameters:
      option - - option code to be set.
    • _processCommand

      void _processCommand(int command)
      Processes a COMMAND.
      Parameters:
      command - - option code to be set.
    • _processDo

      void _processDo(int option) throws IOException
      Processes a DO request.
      Parameters:
      option - - option code to be set.
      Throws:
      IOException - - Exception in I/O.
    • _processDont

      void _processDont(int option) throws IOException
      Processes a DONT request.
      Parameters:
      option - - option code to be set.
      Throws:
      IOException - - Exception in I/O.
    • _processWill

      void _processWill(int option) throws IOException
      Processes a WILL request.
      Parameters:
      option - - option code to be set.
      Throws:
      IOException - - Exception in I/O.
    • _processWont

      void _processWont(int option) throws IOException
      Processes a WONT request.
      Parameters:
      option - - option code to be set.
      Throws:
      IOException - - Exception in I/O.
    • _processSuboption

      void _processSuboption(int[] suboption, int suboptionLength) throws IOException
      Processes a suboption negotiation.
      Parameters:
      suboption - - subnegotiation data received
      suboptionLength - - length of data received
      Throws:
      IOException - - Exception in I/O.
    • _sendTerminalType

      final void _sendTerminalType() throws IOException
      Sends terminal type information.
      Throws:
      IOException - - Exception in I/O.
    • _sendSubnegotiation

      final void _sendSubnegotiation(int[] subn) throws IOException
      Manages subnegotiation for Terminal Type.
      Parameters:
      subn - - subnegotiation data to be sent
      Throws:
      IOException - - Exception in I/O.
    • _sendCommand

      final void _sendCommand(byte cmd) throws IOException
      Sends a command, automatically adds IAC prefix and flushes the output.
      Parameters:
      cmd - - command data to be sent
      Throws:
      IOException - - Exception in I/O.
      Since:
      3.0
    • _processAYTResponse

      final void _processAYTResponse()
      Processes the response of an AYT
    • _connectAction_

      protected void _connectAction_() throws IOException
      Called upon connection.
      Overrides:
      _connectAction_ in class SocketClient
      Throws:
      IOException - - Exception in I/O.
    • _sendDo

      final void _sendDo(int option) throws IOException
      Sends a DO.
      Parameters:
      option - - Option code.
      Throws:
      IOException - - Exception in I/O.
    • _requestDo

      final void _requestDo(int option) throws IOException
      Requests a DO.
      Parameters:
      option - - Option code.
      Throws:
      IOException - - Exception in I/O.
    • _sendDont

      final void _sendDont(int option) throws IOException
      Sends a DONT.
      Parameters:
      option - - Option code.
      Throws:
      IOException - - Exception in I/O.
    • _requestDont

      final void _requestDont(int option) throws IOException
      Requests a DONT.
      Parameters:
      option - - Option code.
      Throws:
      IOException - - Exception in I/O.
    • _sendWill

      final void _sendWill(int option) throws IOException
      Sends a WILL.
      Parameters:
      option - - Option code.
      Throws:
      IOException - - Exception in I/O.
    • _requestWill

      final void _requestWill(int option) throws IOException
      Requests a WILL.
      Parameters:
      option - - Option code.
      Throws:
      IOException - - Exception in I/O.
    • _sendWont

      final void _sendWont(int option) throws IOException
      Sends a WONT.
      Parameters:
      option - - Option code.
      Throws:
      IOException - - Exception in I/O.
    • _requestWont

      final void _requestWont(int option) throws IOException
      Requests a WONT.
      Parameters:
      option - - Option code.
      Throws:
      IOException - - Exception in I/O.
    • _sendByte

      final void _sendByte(int b) throws IOException
      Sends a byte.
      Parameters:
      b - - byte to send
      Throws:
      IOException - - Exception in I/O.
    • _sendAYT

      final boolean _sendAYT(long timeout) throws IOException, IllegalArgumentException, InterruptedException
      Sends an Are You There sequence and waits for the result.
      Parameters:
      timeout - - Time to wait for a response (millis.)
      Returns:
      true if AYT received a response, false otherwise
      Throws:
      IOException - - Exception in I/O.
      IllegalArgumentException - - Illegal argument
      InterruptedException - - Interrupted during wait.
    • addOptionHandler

      void addOptionHandler(TelnetOptionHandler opthand) throws InvalidTelnetOptionException, IOException
      Registers a new TelnetOptionHandler for this telnet to use.
      Parameters:
      opthand - - option handler to be registered.
      Throws:
      InvalidTelnetOptionException - - The option code is invalid.
      IOException - on error
    • deleteOptionHandler

      void deleteOptionHandler(int optcode) throws InvalidTelnetOptionException, IOException
      Unregisters a TelnetOptionHandler.
      Parameters:
      optcode - - Code of the option to be unregistered.
      Throws:
      InvalidTelnetOptionException - - The option code is invalid.
      IOException - on error
    • _registerSpyStream

      void _registerSpyStream(OutputStream spystream)
      Registers an OutputStream for spying what's going on in the Telnet session.
      Parameters:
      spystream - - OutputStream on which session activity will be echoed.
    • _stopSpyStream

      void _stopSpyStream()
      Stops spying this Telnet.
    • _spyRead

      void _spyRead(int ch)
      Sends a read char on the spy stream.
      Parameters:
      ch - - character read from the session
    • _spyWrite

      void _spyWrite(int ch)
      Sends a written char on the spy stream.
      Parameters:
      ch - - character written to the session
    • registerNotifHandler

      public void registerNotifHandler(TelnetNotificationHandler notifhand)
      Registers a notification handler to which will be sent notifications of received telnet option negotiation commands.
      Parameters:
      notifhand - - TelnetNotificationHandler to be registered
    • unregisterNotifHandler

      public void unregisterNotifHandler()
      Unregisters the current notification handler.