Example usage for org.apache.commons.net.telnet InvalidTelnetOptionException getMessage

List of usage examples for org.apache.commons.net.telnet InvalidTelnetOptionException getMessage

Introduction

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

Prototype

@Override
public String getMessage() 

Source Link

Document

Gets the error message of ths exception.

Usage

From source file:collabedit.Telnet.java

public static void init() {
    String remoteip = "23.102.136.121";
    int remoteport = 4500;
    tc = new TelnetClient();
    TerminalTypeOptionHandler ttopt = new TerminalTypeOptionHandler("VT100", false, false, true, false);
    EchoOptionHandler echoopt = new EchoOptionHandler(true, false, true, false);
    SuppressGAOptionHandler gaopt = new SuppressGAOptionHandler(true, true, true, true);

    try {/*w  w w  . jav a 2s  .c  o m*/
        tc.addOptionHandler(ttopt);
        tc.addOptionHandler(echoopt);
        tc.addOptionHandler(gaopt);
    } catch (InvalidTelnetOptionException e) {
        System.err.println("Error registering option handlers: " + e.getMessage());
    }

    try {
        tc.connect(remoteip, remoteport);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    Thread reader = new Thread(new Telnet());
    tc.registerNotifHandler(new Telnet());
    System.out.println("TelnetClientExample");
    System.out.println("Type AYT to send an AYT telnet command");
    System.out.println("Type OPT to print a report of status of options (0-24)");
    System.out.println("Type REGISTER to register a new SimpleOptionHandler");
    System.out.println("Type UNREGISTER to unregister an OptionHandler");
    System.out.println("Type SPY to register the spy (connect to port 3333 to spy)");
    System.out.println("Type UNSPY to stop spying the connection");

    reader.start();
    OutputStream outstr = tc.getOutputStream();
    System.out.println("Telnet started");

}

From source file:com.kz.pipeCutter.MyTelnetClient.java

public TelnetClient getTelnetClient() {

    if (tc == null) {
        TelnetClient tc1 = new TelnetClient();

        TerminalTypeOptionHandler ttopt = new TerminalTypeOptionHandler("VT100", false, false, true, false);
        EchoOptionHandler echoopt = new EchoOptionHandler(true, false, true, false);
        SuppressGAOptionHandler gaopt = new SuppressGAOptionHandler(true, true, true, true);

        try {//from  w w  w  .j  a v  a2s.c  o  m
            tc1.addOptionHandler(ttopt);
            tc1.addOptionHandler(echoopt);
            tc1.addOptionHandler(gaopt);
        } catch (InvalidTelnetOptionException e) {
            System.err.println("Error registering option handlers: " + e.getMessage());
        }

        boolean end_loop = false;
        try {
            //tc1.setDefaultTimeout(4);
            tc1.connect(SmoothieUploader.smoothieIP, this.remotePort);
            tc1.registerNotifHandler(this);
            tc = tc1;
        } catch (IOException e) {
            System.err.println("Exception while connecting to: " + this.ipAddress + ":" + this.remotePort + "\n"
                    + e.getMessage());
        }

    }
    return tc;
}