com.dalsemi.shell.server.telnet
Class TelnetServer
java.lang.Object
|
+--java.lang.Thread
|
+--com.dalsemi.shell.server.Server
|
+--com.dalsemi.shell.server.telnet.TelnetServer
- public class TelnetServer
- extends Server
A simple server that uses the Telnet protocol as described in RFC 854. This server uses a ServerSocket to listen
on the specified port (defaults to port 23) for Telnet connection requests. For each connection made,
a Telnet session is created. All command processing is handled by the Telnet session, not this server.
Constructor Summary |
TelnetServer()
Prepares the Telnet server to listen on the well known Telnet port (23). |
TelnetServer(int port)
Prepares the Telnet server to listen on an arbitrary port. |
Method Summary |
protected Session |
acceptNewSession()
Waits for a connection request. |
protected void |
closeAllPorts()
Closes the ServerSocket used to listen for connections. |
static String |
getWelcomeFile()
Gets the name of the file to be displayed when after a user logs in to this server. |
static boolean |
isRootAllowed()
Indicates whether root access is allowed to this Telnet server. |
Methods inherited from class java.lang.Thread |
activeCount,
checkAccess,
countStackFrames,
currentThread,
destroy,
dumpStack,
enumerate,
getName,
getPriority,
getThreadGroup,
interrupt,
interrupted,
isAlive,
isDaemon,
isInterrupted,
join,
join,
join,
resume,
setDaemon,
setName,
setPriority,
sleep,
sleep,
start,
stop,
stop,
suspend,
toString,
yield |
TelnetServer
public TelnetServer()
throws IOException
- Prepares the Telnet server to listen on the well known Telnet port (23). The server will not
be started and no connections will be accepted until its
run()
method is executed.
TelnetServer
public TelnetServer(int port)
throws IOException
- Prepares the Telnet server to listen on an arbitrary port. The server will not
be started and no connections will be accepted until its
run()
method is executed.
getWelcomeFile
public static String getWelcomeFile()
- Gets the name of the file to be displayed when after a user logs in to this server.
This file is specified by setting the "TELNET_WELCOME" environment variable equal to
the name of the file. This method will always return the value the variable had
when the server was constructed. Changing the value of environment variable after
creating the server will have no effect.
- Returns:
- the name of the welcome file to display, or
null
if no welcome file was specified
isRootAllowed
public static boolean isRootAllowed()
- Indicates whether root access is allowed to this Telnet server. This
is specified with the environment variable "TELNET_ROOT_ALLOWED". Set the
variable to "false" to disallow root login. All other values will
be interpreted as
true
and root logins will be accepted.
This method will always return the value the variable had when the server
was constructed. Changing the value of environment variable after
creating the server will have no effect.
- Returns:
true
if root is allowed to login
acceptNewSession
protected Session acceptNewSession()
- Description copied from class: Server
- Waits for a connection request. This method should block until a request is received.
When a request is made, it should create, initialize, and return a
new Session to handle that connection.
- Overrides:
- acceptNewSession in class Server
- Tags copied from class: Server
- Returns:
- a new Session
closeAllPorts
protected void closeAllPorts()
throws IOException
- Closes the ServerSocket used to listen for connections.
- Overrides:
- closeAllPorts in class Server