Module com.googlecode.lanterna
Class TelnetTerminalServer
java.lang.Object
com.googlecode.lanterna.terminal.ansi.TelnetTerminalServer
This class implements a Telnet server, capable of accepting multiple clients and presenting each one as their own
Terminal. You need to tell it at least what port to listen on and then it create a Server socket listening for
incoming connections. Use
acceptConnection()
to wait for the next incoming connection, it will be returned as
a TelnetTerminal
object that represents the client and which will be the way for the server to send content
to this client. Next connecting client (through acceptConnection()
will get a different
TelnetTerminal
, i.e. their content will not be in sync automatically but considered as two different
terminals.- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTelnetTerminalServer
(int port) Creates a new TelnetTerminalServer on a specific portTelnetTerminalServer
(int port, Charset charset) Creates a new TelnetTerminalServer on a specific port, using a certain character setTelnetTerminalServer
(ServerSocketFactory serverSocketFactory, int port) Creates a new TelnetTerminalServer on a specific port through a ServerSocketFactoryTelnetTerminalServer
(ServerSocketFactory serverSocketFactory, int port, Charset charset) Creates a new TelnetTerminalServer on a specific port through a ServerSocketFactory with a certain Charset -
Method Summary
Modifier and TypeMethodDescriptionWaits for the next client to connect in to our server and returns a Terminal implementation, TelnetTerminal, that represents the remote terminal this client is running.void
close()
Closes the server socket, accepting no new connection.Returns the actual server socket used by this object.
-
Field Details
-
charset
-
serverSocket
-
-
Constructor Details
-
TelnetTerminalServer
Creates a new TelnetTerminalServer on a specific port- Parameters:
port
- Port to listen for incoming telnet connections- Throws:
IOException
- If there was an underlying I/O exception
-
TelnetTerminalServer
Creates a new TelnetTerminalServer on a specific port, using a certain character set- Parameters:
port
- Port to listen for incoming telnet connectionscharset
- Character set to use- Throws:
IOException
- If there was an underlying I/O exception
-
TelnetTerminalServer
Creates a new TelnetTerminalServer on a specific port through a ServerSocketFactory- Parameters:
serverSocketFactory
- ServerSocketFactory to use when creating the ServerSocketport
- Port to listen for incoming telnet connections- Throws:
IOException
- If there was an underlying I/O exception
-
TelnetTerminalServer
public TelnetTerminalServer(ServerSocketFactory serverSocketFactory, int port, Charset charset) throws IOException Creates a new TelnetTerminalServer on a specific port through a ServerSocketFactory with a certain Charset- Parameters:
serverSocketFactory
- ServerSocketFactory to use when creating the ServerSocketport
- Port to listen for incoming telnet connectionscharset
- Character set to use- Throws:
IOException
- If there was an underlying I/O exception
-
-
Method Details
-
getServerSocket
Returns the actual server socket used by this object. Can be used to tweak settings but be careful!- Returns:
- Underlying ServerSocket
-
acceptConnection
Waits for the next client to connect in to our server and returns a Terminal implementation, TelnetTerminal, that represents the remote terminal this client is running. The terminal can be used just like any other Terminal, but keep in mind that all operations are sent over the network.- Returns:
- TelnetTerminal for the remote client's terminal
- Throws:
IOException
- If there was an underlying I/O exception
-
close
Closes the server socket, accepting no new connection. Any call to acceptConnection() after this will fail.- Throws:
IOException
- If there was an underlying I/O exception
-