com.foxsmart.ic.net
Class CommonsTelnetProtocolHandler

java.lang.Object
  extended by com.foxsmart.ic.net.AbstractCliProtocolHandler
      extended by com.foxsmart.ic.net.CommonsTelnetProtocolHandler
All Implemented Interfaces:
CliProtocolHandler, ProtocolHandler

public class CommonsTelnetProtocolHandler
extends AbstractCliProtocolHandler

The CommonsTelnetProtocolHandler class helps with the handling of sending and receiving of data to and from a telnet client.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.foxsmart.ic.net.ProtocolHandler
ProtocolHandler.Protocol
 
Field Summary
static int DEFAULT_TELNET_PORT
          The default telnet socket port.
protected  com.foxsmart.ic.cots.apache.commons.net.telnet.TelnetClient telnetClient
          The telnet client that will perform the work.
 
Fields inherited from class com.foxsmart.ic.net.AbstractCliProtocolHandler
defaultNoDataReadDelay, defaultProtocolTimeout, log, PASSWORD_MASK
 
Fields inherited from interface com.foxsmart.ic.net.CliProtocolHandler
CR, DEFAULT_NO_DATA_READ_DELAY, PASSWORD_PROMPT, USERNAME_PROMPT
 
Fields inherited from interface com.foxsmart.ic.net.ProtocolHandler
DEFAULT_PROTOCOL_TIMEOUT_SECONDS
 
Constructor Summary
CommonsTelnetProtocolHandler()
          Default Constructor.
 
Method Summary
 void connect(java.lang.String hostname, java.lang.Integer port, java.lang.String username, java.lang.String password, java.lang.Integer timeout)
          Connects to the hostname at the specified port number and authenticates with the remote device.
 void disconnect()
          Disconnects the socket connection.
 java.io.InputStream getInputStream()
          Returns the connection input stream.
 java.io.OutputStream getOutputStream()
          Returns the connection output stream.
 ProtocolHandler.Protocol getProtocol()
          Returns the TELNET protocol.
 boolean isConnected()
          Returns true if the client is currently connected to a server.
 
Methods inherited from class com.foxsmart.ic.net.AbstractCliProtocolHandler
expect, expect, expect, expect, expect, expect, getAscii, getAvailable, getDefaultNoDataReadDelay, getDefaultProtocolTimeout, getPasswordUsed, getUsernameUsed, read, read, sendCommand, sendCommand, setDefaultNoDataReadDelay, setDefaultProtocolTimeout, setPasswordUsed, setUsernameUsed, toString, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_TELNET_PORT

public static final int DEFAULT_TELNET_PORT
The default telnet socket port.

See Also:
Constant Field Values

telnetClient

protected com.foxsmart.ic.cots.apache.commons.net.telnet.TelnetClient telnetClient
The telnet client that will perform the work.

Constructor Detail

CommonsTelnetProtocolHandler

public CommonsTelnetProtocolHandler()
Default Constructor.

Method Detail

getProtocol

public ProtocolHandler.Protocol getProtocol()
Returns the TELNET protocol.

Returns:
the TELNET protocol.

connect

public void connect(java.lang.String hostname,
                    java.lang.Integer port,
                    java.lang.String username,
                    java.lang.String password,
                    java.lang.Integer timeout)
             throws java.lang.Exception
Description copied from interface: CliProtocolHandler
Connects to the hostname at the specified port number and authenticates with the remote device. A socket connection will be established when this call is complete.

Parameters:
hostname - The name of the remote host.
port - The port to connect to on the remote host. If null is passed in, a default port will be used.
username - The username to connect with. Null should be passed in if no username is required.
password - The password to connect with. Null should be passed in if no password is required.
timeout - The timeout in seconds. If null is passed in, a default timeout will be used.
Throws:
AuthenticationFailedException - when a successful connection could not be made
java.net.SocketException - if the socket timeout could not be set.
java.io.IOException - if the socket could not be opened. In most cases you will only want to catch IOException since SocketException is derived from it.
ThreadTimeoutException - if a timeout occurred while connecting to the router.
java.net.UnknownHostException - If the hostname cannot be resolved.
java.lang.Exception - if any other problems were encountered.
See Also:
Note that the timeout is not used.

isConnected

public boolean isConnected()
Returns true if the client is currently connected to a server.

Returns:
True if the client is currently connected to a server, false otherwise.

disconnect

public void disconnect()
                throws java.io.IOException
Disconnects the socket connection. You should call this method after you've finished using the class instance and also before you call connect again.

Specified by:
disconnect in interface CliProtocolHandler
Overrides:
disconnect in class AbstractCliProtocolHandler
Throws:
java.io.IOException - If there is an error closing the socket.

getInputStream

public java.io.InputStream getInputStream()
Returns the connection input stream. You should not close the stream when you finish with it. Rather, you should call disconnect.

Returns:
The connection input stream.

getOutputStream

public java.io.OutputStream getOutputStream()
Returns the connection output stream.

Returns:
The connection output stream.


Copyright © 2005-2008 Fox Smart, Inc. All Rights Reserved.