- java.lang.Object
-
- com.googlecode.lanterna.terminal.AbstractTerminal
-
- com.googlecode.lanterna.terminal.ansi.StreamBasedTerminal
-
- com.googlecode.lanterna.terminal.ansi.ANSITerminal
-
- com.googlecode.lanterna.terminal.ansi.TelnetTerminal
-
- All Implemented Interfaces:
Scrollable,InputProvider,ExtendedTerminal,Terminal,java.io.Closeable,java.lang.AutoCloseable
public class TelnetTerminal extends ANSITerminal
This class is used by theTelnetTerminalServerclass 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 aTelnetTerminalServerand 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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTelnetTerminal.NegotiationStateThis class contains some of the various states that the Telnet negotiation protocol defines.private static interfaceTelnetTerminal.TelnetClientEventListenerprivate static classTelnetTerminal.TelnetClientIACFilterer
-
Field Summary
Fields Modifier and Type Field Description private TelnetTerminal.NegotiationStatenegotiationStateprivate java.net.Socketsocket
-
Constructor Summary
Constructors Modifier Constructor Description privateTelnetTerminal(java.net.Socket socket, TelnetTerminal.TelnetClientIACFilterer inputStream, java.io.OutputStream outputStream, java.nio.charset.Charset terminalCharset)(package private)TelnetTerminal(java.net.Socket socket, java.nio.charset.Charset terminalCharset)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the socket to the client, effectively ending the telnet session and the terminal.private static intconvertTwoBytesToInt2(byte b1, byte b2)TelnetTerminal.NegotiationStategetNegotiationState()Retrieves the current negotiation state with the client, containing details on what options have been enabled and what the client has said it supports.java.net.SocketAddressgetRemoteSocketAddress()Returns the socket address for the remote endpoint of the telnet connectionprivate voidsetEchoOff()private voidsetLineMode0()private voidsetResizeNotificationOn()-
Methods inherited from class com.googlecode.lanterna.terminal.ansi.ANSITerminal
clearScreen, deiconify, disableSGR, enableSGR, enterPrivateMode, exitPrivateMode, findTerminalSize, getCursorPosition, getDefaultKeyDecodingProfile, getTerminalSize, iconify, isInPrivateMode, maximize, pollInput, popTitle, pushTitle, readInput, reportPosition, resetColorAndSGR, restoreCursorPosition, saveCursorPosition, scrollLines, setBackgroundColor, setCursorPosition, setCursorPosition, setCursorVisible, setForegroundColor, setMouseCaptureMode, setTerminalSize, setTitle, unmaximize
-
Methods inherited from class com.googlecode.lanterna.terminal.ansi.StreamBasedTerminal
bell, enquireTerminal, flush, getCharset, getInputDecoder, putCharacter, putString, resetMemorizedCursorPosition, translateCharacter, waitForCursorPositionReport, writeToTerminal
-
Methods inherited from class com.googlecode.lanterna.terminal.AbstractTerminal
addResizeListener, newTextGraphics, onResized, onResized, removeResizeListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.googlecode.lanterna.terminal.Terminal
addResizeListener, bell, enquireTerminal, flush, newTextGraphics, putCharacter, putString, removeResizeListener
-
-
-
-
Field Detail
-
socket
private final java.net.Socket socket
-
negotiationState
private final TelnetTerminal.NegotiationState negotiationState
-
-
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.IOExceptionCloses the socket to the client, effectively ending the telnet session and the terminal.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfaceTerminal- Overrides:
closein classANSITerminal- Throws:
java.io.IOException- If there was an underlying I/O error
-
convertTwoBytesToInt2
private static int convertTwoBytesToInt2(byte b1, byte b2)
-
-