So, I have this class that uses the org.apache.commons.net.telnet.TelnetClient class. It attempts to send commands and read the response.
public class Automa
Interesting problem. To summarize my effort: I didn't get it working properly But here are some of my findings:
You cannot write IAC DON'T ECHO
directly to the data channel, this is done with commands and options like this example
int[] msg = {TelnetCommand.DONT,TelnetOption.ECHO};
telnet.sendSubnegotiation(msg);
You can register telnet.registerNotifHandler(new MyNotificationHandler());
to debug the commands during connection setup
public class MyNotificationHandler implements TelnetNotificationHandler
{
@Override
public void receivedNegotiation(int negotiation_code, int option_code)
{
System.out.println("--->"+get(negotiation_code)+" "
+TelnetOption.getOption(option_code));
}
private String get(int i)
{
if(i==TelnetNotificationHandler.RECEIVED_DO){return "RECEIVED_DO";}
else if(i==TelnetNotificationHandler.RECEIVED_DONT){return "RECEIVED_DONT";}
else if(i==TelnetNotificationHandler.RECEIVED_WILL){return "RECEIVED_WILL";}
else if(i==TelnetNotificationHandler.RECEIVED_WONT){return "RECEIVED_WONT";}
else if(i==TelnetNotificationHandler.RECEIVED_COMMAND)
{return "RECEIVED_COMMAND";}
return "UNKNOWN";
}
}