Class TelnetComm

java.lang.Object
com.iizix.term.comm.TelnetComm

public class TelnetComm extends Object
Class to handle the Telnet protocol for 3270 and 5250.
Author:
Christopher Mindus
  • Constructor Details

    • TelnetComm

      public TelnetComm(SessionInfo sessionInfo, TelnetCommProps properties, boolean is3270, Worker worker, TelnetCommListener listener, SSLEngine engine) throws IOException
      Creates a new Telnet Client Communication channel as UNINITIALIZED.
      Parameters:
      sessionInfo - Session information.
      properties - The Telnet properties.
      is3270 - Flag for 3270.
      worker - The worker thread for socket processing.
      listener - The listener for Telnet events.
      engine - The SSL engine, or null for plain socket.
      Throws:
      IOException - for I/O errors.
  • Method Details

    • getSocketCommNIO

      public SocketCommNIO getSocketCommNIO()
      Gets the NIO Socket Communication instance.
      Returns:
      The socket communication instance.
    • getTerminalType

      public String getTerminalType()
      Gets the negotiated terminal type, null for none.
      Returns:
      The terminal type, null for none.
    • getProperties

      public TelnetCommProps getProperties()
      Gets the Telnet properties.
      Returns:
      The telnet settings.
    • getCodepageConverter

      public CodepageConverter getCodepageConverter()
      Gets the codepage converter for EBCDIC characters.
      Returns:
      The codepage converter.
    • open

      public void open() throws IOException
      Opens the communication.
      Throws:
      IOException - For I/O errors.
    • hasBeenOpen

      public boolean hasBeenOpen()
      Checks if the session has been opened, and if so cannot be reopened but needs to have a new instance.
      Returns:
      true if opened.
    • getState

      public State getState()
      Gets the state of the connection.
      Returns:
      Connection state.
    • isClosed

      public boolean isClosed()
      Checks if the connection is disposed of.
      Returns:
      true for closed.
    • close

      public boolean close()
      Call this method to close the socket.
      Returns:
      true if closed, false if already closed.
    • write

      public void write(byte[] buf) throws IOException
      Writes a raw buffer to the output followed by a flush.
      Parameters:
      buf - Data to send.
      Throws:
      IOException - For send failures.
    • write

      public void write(byte[] buf, int n) throws IOException
      Writes an amount of bytes. The data is appended with and end-of-record (IAC EOR). Each 0xFF character in the buffer is escaped with 0xFF (i.e. IAC IAC).
      Parameters:
      buf - The byte array to write.
      n - Count of bytes to write.
      Throws:
      IOException - if an I/O error occurs.
    • writeRaw

      public void writeRaw(byte[] buf) throws IOException
      Writes a raw buffer to the output followed by a flush.
      Parameters:
      buf - The byte buffer.
      Throws:
      IOException - for send IO failures.
    • writeRaw

      public void writeRaw(byte[] buf, int count) throws IOException
      Writes a raw buffer to the output followed by a flush.
      Parameters:
      buf - The byte buffer.
      count - The count of bytes from beginning of buffer to write.
      Throws:
      IOException - for send IO failures.
    • getDeviceName

      public String getDeviceName()
      Gets the device name of the session.
      Returns:
      null if no device name exists.
    • sendSSCPLUData

      public void sendSSCPLUData(byte[] buf, int n) throws IOException
      Sends SSCP LU data for a TN3270E session.
      Parameters:
      buf - The buffer.
      n - The count of bytes.
      Throws:
      IOException - if an I/O error occurs.
    • sendSpecialKey

      public boolean sendSpecialKey(int param) throws IOException
      Sends TN3270E special key (param=0 is Attention and param=1 is SysReq).
      Parameters:
      param - The special send key.
      Returns:
      false if this special key is not supported.
      Throws:
      IOException - if an I/O error occurs.