Class TelnetTerminal

  • All Implemented Interfaces:
    Scrollable, InputProvider, ExtendedTerminal, Terminal, java.io.Closeable, java.lang.AutoCloseable

    public class TelnetTerminal
    extends ANSITerminal
    This class is used by the TelnetTerminalServer class when a client has connected in; this class will be the interaction point for that client. All operations are sent to the client over the network socket and some of the meta-operations (like echo mode) are communicated using Telnet negotiation language. You can't create objects of this class directly; they are created for you when you are listening for incoming connections using a TelnetTerminalServer and a client connects.

    A good resource on telnet communication is http://www.tcpipguide.com/free/t_TelnetProtocol.htm
    Also here: http://support.microsoft.com/kb/231866

    See Also:
    TelnetTerminalServer
    • Constructor Detail

      • TelnetTerminal

        TelnetTerminal​(java.net.Socket socket,
                       java.nio.charset.Charset terminalCharset)
                throws java.io.IOException
        Throws:
        java.io.IOException
      • TelnetTerminal

        private TelnetTerminal​(java.net.Socket socket,
                               TelnetTerminal.TelnetClientIACFilterer inputStream,
                               java.io.OutputStream outputStream,
                               java.nio.charset.Charset terminalCharset)
                        throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • getRemoteSocketAddress

        public java.net.SocketAddress getRemoteSocketAddress()
        Returns the socket address for the remote endpoint of the telnet connection
        Returns:
        SocketAddress representing the remote client
      • setEchoOff

        private void setEchoOff()
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • setLineMode0

        private void setLineMode0()
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • setResizeNotificationOn

        private void setResizeNotificationOn()
                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • getNegotiationState

        public TelnetTerminal.NegotiationState getNegotiationState()
        Retrieves the current negotiation state with the client, containing details on what options have been enabled and what the client has said it supports.
        Returns:
        The current negotiation state for this client
      • close

        public void close()
                   throws java.io.IOException
        Closes the socket to the client, effectively ending the telnet session and the terminal.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface Terminal
        Overrides:
        close in class ANSITerminal
        Throws:
        java.io.IOException - If there was an underlying I/O error
      • convertTwoBytesToInt2

        private static int convertTwoBytesToInt2​(byte b1,
                                                 byte b2)