Performing option subnegotiation

Top  Previous  Next

The telnet server may request that an option be used by sending a DO OPTION (or WILL OPTION) command where OPTION is the option code for the requested option. The client may accept the option by returning a WILL OPTION (or DO OPTION) command. If the option requires additional information then option sub negotiation will be required.

 

An example of an option requiring sub negotiation is the TERMINAL-TYPE option. Upon both parties agreeing to use the TERMINAL-TYPE option the server will ask the client for the terminal type that the client wishes to use (e.g. dumb, vt100). The client will send a SB OPTION command that includes the desired terminal type as one of its arguments.

 

By default the TelnetOption class cannot perform sub negotiation as it does not include any member variables to store the sub negotiation data (e.g. terminal type). Options requiring sub negotiation must extend the TelnetOption class, provide member variables for storing sub negotiation data and overload the TelnetOption#writeSubnegotiation and TelnetOption#readSubnegotiation methods.

 

To capture the option sub negotiation request and send the sub negotiation data the TelnetListener#doSubOption and Telnet#sendOptionSubnegotiation methods are used. In the example below the TerminalType (a subclass of TelnetOption ) class is used demonstrating sub negotiation.

 

Example

 

public void doSubOption(DoSubOptionEvent event) {

 TelnetOption option = event.getOption();

 

// check if TERMINAL-TYPE option

if(option.getOptionCode() == 24) {

   

// create new TerminalType instance to emulate vt100 terminal

 TerminalType tt = new TerminalType("vt100");    

 

// send subnegotation data to server

 telnet.sendOptionSubnegotiation(tt);

  }    

}





Home | Company | Products | Solutions | Purchase | Support | Services | Blog

© 2021 JSCAPE LLC