Example usage for org.apache.commons.net.telnet EchoOptionHandler EchoOptionHandler

List of usage examples for org.apache.commons.net.telnet EchoOptionHandler EchoOptionHandler

Introduction

In this page you can find the example usage for org.apache.commons.net.telnet EchoOptionHandler EchoOptionHandler.

Prototype

public EchoOptionHandler() 

Source Link

Document

Constructor for the EchoOptionHandler.

Usage

From source file:org.opennaas.extensions.transports.telnet.TelnetTransport.java

public void connect() throws TransportException {
    logger.info("Telnet Transport trying to connect...");

    // Create a new telnet client
    telnetClient = new TelnetClient();

    // VT100 terminal type will be subnegotiated
    TerminalTypeOptionHandler ttopt = new TerminalTypeOptionHandler("VT100", false, false, true, false);
    // WILL SUPPRESS-GA, DO SUPPRESS-GA options
    SuppressGAOptionHandler gaopt = new SuppressGAOptionHandler(true, true, true, true);
    // WON'T ECHO, DON'T ECHO
    EchoOptionHandler echoopt = new EchoOptionHandler();

    try {/*from   ww  w .  j ava2  s.com*/
        // set telnet client options
        telnetClient.addOptionHandler(ttopt);
        telnetClient.addOptionHandler(gaopt);
        telnetClient.addOptionHandler(echoopt);

        // connect
        telnetClient.connect(host, Integer.parseInt(port));

        // set the read timeout
        telnetClient.setSoTimeout(READ_TIMEOUT);

        // Initialize the print writer
        outPrint = new PrintWriter(telnetClient.getOutputStream(), true);
    } catch (Exception e) {
        e.printStackTrace();
        throw new TransportException("Could not connect, unable to open telnet session " + e.getMessage());
    }
}