Class telnet

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--telnet

public class telnet
extends java.applet.Applet
implements java.lang.Runnable, TerminalHost, StatusPeer

A telnet implementation that supports different terminal emulations.

Version:
$Id: telnet.java,v 1.21 1999/03/04 07:45:50 leo Exp $
Author:
Matthias L. Jugel, Marcus Meißner
See Also:
Serialized Form

Field Summary
protected  java.lang.String address
          The host address to connect to.
protected  java.lang.String emulation
          Emulation type (default is vt320).
protected  java.util.Vector modules
          Dynamically loaded modules are stored here.
 java.util.Hashtable params
          This Hashtable contains information retrievable by getParameter() in case the program is run as an application and the AppletStub is missing.
protected  int port
          The port number (default ist 23).
protected  java.lang.String proxy
          The proxy ip address.
protected  int proxyport
          The proxy port number.
protected  Terminal term
          The terminal emulation (dynamically loaded).
protected  TelnetIO tio
          The telnet io methods.
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
telnet()
           
 
Method Summary
 boolean connect()
          Connect to the specified host and port but don't break existing connections.
 boolean connect(java.lang.String host)
          Connect to the specified host and port but don't break existing connections.
 boolean connect(java.lang.String host, int prt)
          Connect to the specified host and port but don't break existing connections.
 boolean disconnect()
          Disconnect from the remote host.
 java.lang.String getAppletInfo()
          Retrieve the current version of the applet.
 java.lang.String getParameter(java.lang.String name)
          We override the Applet method getParameter() to be able to handle parameters even as application.
 java.lang.String[][] getParameterInfo()
          Retrieve parameter tag information.
 void init()
          Initialize applet.
static void main(java.lang.String[] args)
          The main function is called on startup of the application.
 java.lang.Object notifyStatus(java.util.Vector status)
          This method is called when telnet needs to be notified of status changes.
 void run()
          Try to read data from the sockets and put it on the terminal.
 boolean send(java.lang.String str)
          Send a String to the remote host.
 void start()
          Upon start of the applet try to create a new connection.
 void stop()
          Disconnect when the applet is stopped.
 boolean writeToSocket(java.lang.String str)
          Send a String to the remote Host.
 void writeToUser(java.lang.String str)
          Send a String to the users terminal
 
Methods inherited from class java.applet.Applet
destroy, getAppletContext, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tio

protected TelnetIO tio
The telnet io methods.
See Also:
TelnetIO

term

protected Terminal term
The terminal emulation (dynamically loaded).
See Also:
emulation, Terminal, TerminalHost

address

protected java.lang.String address
The host address to connect to. This is retrieved from the PARAM tag "address".

port

protected int port
The port number (default ist 23). This can be specified as the PARAM tag "port".

proxy

protected java.lang.String proxy
The proxy ip address. If this variable is set telnet will try to connect to this address and then send a string to tell the relay where the target host is.
See Also:
address

proxyport

protected int proxyport
The proxy port number. This is the port where the relay is expected to listen for incoming connections.
See Also:
proxy, port

emulation

protected java.lang.String emulation
Emulation type (default is vt320). This can be specified as the PARAM tag "emulation".
See Also:
term, Terminal, TerminalHost

modules

protected java.util.Vector modules
Dynamically loaded modules are stored here.

params

public java.util.Hashtable params
This Hashtable contains information retrievable by getParameter() in case the program is run as an application and the AppletStub is missing.
Constructor Detail

telnet

public telnet()
Method Detail

getAppletInfo

public java.lang.String getAppletInfo()
Retrieve the current version of the applet.
Returns:
String a string with the version information.
Overrides:
getAppletInfo in class java.applet.Applet

getParameterInfo

public java.lang.String[][] getParameterInfo()
Retrieve parameter tag information. This includes the tag information from terminal and loaded modules.
Returns:
String an array of array of string with tag information
Overrides:
getParameterInfo in class java.applet.Applet
See Also:
Applet.getParameterInfo()

getParameter

public java.lang.String getParameter(java.lang.String name)
We override the Applet method getParameter() to be able to handle parameters even as application.
Parameters:
name - The name of the queried parameter.
Returns:
the value of the parameter
Overrides:
getParameter in class java.applet.Applet
See Also:
Applet.getParameter(java.lang.String)

main

public static void main(java.lang.String[] args)
The main function is called on startup of the application.

init

public void init()
Initialize applet. This method reads the PARAM tags "address", "port" and "emulation". The emulation class is loaded dynamically. It also loads modules given as parameter "module#".
Overrides:
init in class java.applet.Applet

start

public void start()
Upon start of the applet try to create a new connection.
Overrides:
start in class java.applet.Applet

stop

public final void stop()
Disconnect when the applet is stopped.
Overrides:
stop in class java.applet.Applet

run

public void run()
Try to read data from the sockets and put it on the terminal. This is done until the thread dies or an error occurs.
Specified by:
run in interface java.lang.Runnable

connect

public boolean connect()
Connect to the specified host and port but don't break existing connections. Connects to the host and port specified in the tags.
Returns:
false if connection was unsuccessful

connect

public boolean connect(java.lang.String host)
Connect to the specified host and port but don't break existing connections. Uses the port specified in the tags or 23.
Parameters:
host - destination host address

connect

public boolean connect(java.lang.String host,
                       int prt)
Connect to the specified host and port but don't break existing connections.
Parameters:
host - destination host address
prt - destination hosts port

disconnect

public boolean disconnect()
Disconnect from the remote host.
Returns:
false if there was a problem disconnecting.

send

public boolean send(java.lang.String str)
Send a String to the remote host. Implements display.TerminalHost
Specified by:
send in interface TerminalHost
Parameters:
s - String to be sent
Returns:
true if we are connected
See Also:
TerminalHost

writeToSocket

public boolean writeToSocket(java.lang.String str)
Send a String to the remote Host.
Parameters:
str - String to be sent
Returns:
true if we are connected
See Also:
BSXModule

writeToUser

public void writeToUser(java.lang.String str)
Send a String to the users terminal
Parameters:
str - String to be displayed
Returns:
void
See Also:
BSXModule

notifyStatus

public java.lang.Object notifyStatus(java.util.Vector status)
This method is called when telnet needs to be notified of status changes.
Specified by:
notifyStatus in interface StatusPeer
Parameters:
status - Vector of status information.
Returns:
an object of the information requested.
See Also:
StatusPeer