Example usage for org.apache.commons.net.telnet TelnetClient setReaderThread

List of usage examples for org.apache.commons.net.telnet TelnetClient setReaderThread

Introduction

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

Prototype

public void setReaderThread(boolean flag) 

Source Link

Document

Sets the status of the reader thread.

Usage

From source file:org.mule.transport.telnet.TelnetClientWrapper.java

public TelnetClientWrapper(String host, int port, TelnetMessageDispatcher dispatcher, int waitTime)
        throws IOException {

    TelnetClient client = new TelnetClient();

    TelnetOptionHandler handler = new EchoOptionHandler(true, true, true, true);
    try {/*from ww  w .jav  a 2s  .  c  o m*/
        client.addOptionHandler(handler);
    } catch (InvalidTelnetOptionException e) {
        dispatcher.exceptionThrown(e);
    }
    //TODO enable LINEMODE

    client.connect(host, port);

    if (!client.isConnected()) {
        throw new ConnectException("cannot connect : " + host + ":" + port);
    }

    setWaitTime(waitTime);
    this.responseTimeout = dispatcher.getEndpoint().getResponseTimeout();

    this.client = client;
    this.dispatcher = dispatcher;
    this.encoding = dispatcher.getEndpoint().getEncoding();
    exitStatusCommand = dispatcher.getConnector().getExitStatusCommand();

    reader = new BufferedInputStream(client.getInputStream(), 1024);

    writer = new BufferedOutputStream(client.getOutputStream(), 1024);
    client.setSoTimeout(responseTimeout + waitTime);
    client.setReaderThread(true);

    if (logger.isTraceEnabled())
        logger.trace(BeanUtils.describe(this));
}