Class TelnetClientExample
- java.lang.Object
-
- org.apache.commons.net.examples.telnet.TelnetClientExample
-
- All Implemented Interfaces:
java.lang.Runnable
,TelnetNotificationHandler
public class TelnetClientExample extends java.lang.Object implements java.lang.Runnable, TelnetNotificationHandler
This is a simple example of use of TelnetClient. An external option handler (SimpleTelnetOptionHandler) is used. Initial configuration requested by TelnetClient will be: WILL ECHO, WILL SUPPRESS-GA, DO SUPPRESS-GA. VT100 terminal type will be subnegotiated.Also, use of the sendAYT(), getLocalOptionState(), getRemoteOptionState() is demonstrated. When connected, type AYT to send an AYT command to the server and see the result. Type OPT to see a report of the state of the first 25 options.
-
-
Field Summary
Fields Modifier and Type Field Description private static TelnetClient
tc
-
Fields inherited from interface org.apache.commons.net.telnet.TelnetNotificationHandler
RECEIVED_COMMAND, RECEIVED_DO, RECEIVED_DONT, RECEIVED_WILL, RECEIVED_WONT
-
-
Constructor Summary
Constructors Constructor Description TelnetClientExample()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
main(java.lang.String[] args)
Main for the TelnetClientExample.void
receivedNegotiation(int negotiation_code, int option_code)
Callback method called when TelnetClient receives an option negotiation command.void
run()
Reader thread: Reads lines from the TelnetClient and echoes them on the screen.
-
-
-
Field Detail
-
tc
private static TelnetClient tc
-
-
Method Detail
-
main
public static void main(java.lang.String[] args) throws java.lang.Exception
Main for the TelnetClientExample.- Parameters:
args
- input params- Throws:
java.lang.Exception
- on error
-
receivedNegotiation
public void receivedNegotiation(int negotiation_code, int option_code)
Callback method called when TelnetClient receives an option negotiation command.- Specified by:
receivedNegotiation
in interfaceTelnetNotificationHandler
- Parameters:
negotiation_code
- - type of negotiation command received (RECEIVED_DO, RECEIVED_DONT, RECEIVED_WILL, RECEIVED_WONT, RECEIVED_COMMAND)option_code
- - code of the option negotiated
-
run
public void run()
Reader thread: Reads lines from the TelnetClient and echoes them on the screen.- Specified by:
run
in interfacejava.lang.Runnable
-
-