⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 telnetio.java

📁 java telnet 服务器实现 .
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
        case ECHO:          if (DO_ECHO) {            DO_ECHO = false;          } else {            DO_ECHO = true;          }          break;        case NAWS:          if (DO_NAWS) {            DO_NAWS = false;          } else {            DO_NAWS = true;          }          break;        case TTYPE:          if (DO_TTYPE) {            DO_TTYPE = false;          } else {            DO_TTYPE = true;            getTTYPE();          }          break;        case LINEMODE:          if (DO_LINEMODE) {            DO_LINEMODE = false;            //set false in connection data, so the application knows.            m_ConnectionData.setLineMode(false);          } else {            DO_LINEMODE = true;            negotiateLineMode();          }          break;        case NEWENV:          if (DO_NEWENV) {            DO_NEWENV = false;          } else {            DO_NEWENV = true;            negotiateEnvironment();          }          break;      }    }//enable    /**     * Method that informs internally about the status of the supported     * Negotiation Options.     *     * @param i int that represents requested the Option     * @return Boolean that represents the enabled status     */    private boolean isEnabled(int i) {      switch (i) {        case SUPGA:          return DO_SUPGA;        case ECHO:          return DO_ECHO;        case NAWS:          return DO_NAWS;        case TTYPE:          return DO_TTYPE;        case LINEMODE:          return DO_LINEMODE;        case NEWENV:          return DO_NEWENV;        default:          return false;      }    }//isEnabled    /**     * Method that informs internally about the WILL wait status     * of an option.     *     * @param i that represents requested the Option     * @return Boolean that represents WILL wait status of the Option     */    private boolean waitWILLreply(int i) {      switch (i) {        case SUPGA:          return WAIT_WILL_REPLY_SUPGA;        case ECHO:          return WAIT_WILL_REPLY_ECHO;        case NAWS:          return WAIT_WILL_REPLY_NAWS;        case TTYPE:          return WAIT_WILL_REPLY_TTYPE;        default:          return false;      }    }//waitWILLreply    /**     * Method that informs internally about the DO wait status     * of an option.     *     * @param i Integer that represents requested the Option     * @return Boolean that represents DO wait status of the Option     */    private boolean waitDOreply(int i) {      switch (i) {        case SUPGA:          return WAIT_DO_REPLY_SUPGA;        case ECHO:          return WAIT_DO_REPLY_ECHO;        case NAWS:          return WAIT_DO_REPLY_NAWS;        case TTYPE:          return WAIT_DO_REPLY_TTYPE;        case LINEMODE:          return WAIT_DO_REPLY_LINEMODE;        case NEWENV:          return WAIT_DO_REPLY_NEWENV;        default:          return false;      }    }//waitDOreply    /**     * Method that mutates the wait status of an option in     * negotiation. We need the wait status to keep track of     * negotiation in process. So we cant miss if we started out     * or the other and so on.     *     * @param WHAT   Integer values of  DO or WILL     * @param OPTION Integer that represents the Option     * @param WAIT   Boolean that represents the status of wait that should be set     */    private void setWait(int WHAT, int OPTION, boolean WAIT) {      switch (WHAT) {        case DO:          switch (OPTION) {            case SUPGA:              WAIT_DO_REPLY_SUPGA = WAIT;              break;            case ECHO:              WAIT_DO_REPLY_ECHO = WAIT;              break;            case NAWS:              WAIT_DO_REPLY_NAWS = WAIT;              break;            case TTYPE:              WAIT_DO_REPLY_TTYPE = WAIT;              break;            case LINEMODE:              WAIT_DO_REPLY_LINEMODE = WAIT;              break;            case NEWENV:              WAIT_DO_REPLY_NEWENV = WAIT;              break;          }          break;        case WILL:          switch (OPTION) {            case SUPGA:              WAIT_WILL_REPLY_SUPGA = WAIT;              break;            case ECHO:              WAIT_WILL_REPLY_ECHO = WAIT;              break;            case NAWS:              WAIT_WILL_REPLY_NAWS = WAIT;              break;            case TTYPE:              WAIT_WILL_REPLY_TTYPE = WAIT;              break;          }          break;      }    }//setWait  }//inner class IACHandler  /** Constants declaration ***********************************************///Telnet Protocoll Constants  /**   * Interpret As Command   */  protected static final int IAC = 255;  /**   * Go Ahead <BR> Newer Telnets do not make use of this option   * that allows a specific communication mode.   */  protected static final int GA = 249;  /**   * Negotiation: Will do option   */  protected static final int WILL = 251;  /**   * Negotiation: Wont do option   */  protected static final int WONT = 252;  /**   * Negotiation: Do option   */  protected static final int DO = 253;  /**   * Negotiation:  Dont do option   */  protected static final int DONT = 254;  /**   * Marks start of a subnegotiation.   */  protected static final int SB = 250;  /**   * Marks end of subnegotiation.   */  protected static final int SE = 240;  /**   * No operation   */  protected static final int NOP = 241;  /**   * Data mark its the data part of a SYNCH which helps to clean up the buffers between   * Telnet Server &lt;-&gt; Telnet Client. <BR>   * It should work like this we send a TCP urgent package and &lt;IAC&gt; &lt;DM&gt; the receiver   * should get the urgent package (SYNCH) and just discard everything until he receives   * our &lt;IAC&gt; &lt;DM&gt;.<BR>   * <EM>Remark</EM>:   * <OL>   * <LI>can we send a TCP urgent package?   * <LI>can we make use of the thing at all?   * </OL>   */  protected static final int DM = 242;  /**   * Break   */  protected static final int BRK = 243;  /**   * The following implement the NVT (network virtual terminal) which offers the concept   * of a simple "printer". They are the basical meanings of control possibilities   * on a standard telnet implementation.   */  /**   * Interrupt Process   */  protected static final int IP = 244;  /**   * Abort Output   */  protected static final int AO = 245;  /**   * Are You There   */  protected static final int AYT = 246;  /**   * Erase Char   */  protected static final int EC = 247;  /**   * Erase Line   */  protected static final int EL = 248;  /**   * The following are constants for supported options,   * which can be negotiated based upon the telnet protocol   * specification.   */  /**   * Telnet Option: ECHO   */  protected static final int ECHO = 1;  /**   * Telnet Option: SUPress Go Ahead<br>   * This will be negotiated, all new telnet protocol implementations are   * recommended to do this.   */  protected static final int SUPGA = 3;  /**   * The following options are options for which we also support subnegotiation   * based upon the telnet protocol specification.   */  /**   * Telnet Option: Negotiate About Window Size<br>   * <ul>   * <li>Server request is IAC DO NAWS   * <li>Client response contains subnegotiation with data (columns, rows).   * </ul>   */  protected static final int NAWS = 31;  /**   * Telnet Option: Terminal TYPE <br>   * <ul>   * <li>Server request contains subnegotiation SEND   * <li>Client response contains subnegotiation with data IS,terminal type string   * </ul>   */  protected static final int TTYPE = 24;  /**   * TTYPE subnegotiation: IS   */  protected static final int IS = 0;  /**   * TTYPE subnegotiation: SEND   */  protected static final int SEND = 1;  /**   * Telnet Option: Logout<br>   * This allows nice goodbye to time-outed or unwanted clients.   */  protected static final int LOGOUT = 18;  /**   * Telnet Option: Linemode   * <p/>   * The infamous line mode option.   */  protected static final int LINEMODE = 34;  protected static final int LM_MODE = 1;  protected static final int LM_EDIT = 1;  protected static final int LM_TRAPSIG = 2;  protected static final int LM_MODEACK = 4;  protected static final int LM_FORWARDMASK = 2;  protected static final int LM_SLC = 3;  protected static final int LM_SLC_NOSUPPORT = 0;  protected static final int LM_SLC_DEFAULT = 3;  protected static final int LM_SLC_VALUE = 2;  protected static final int LM_SLC_CANTCHANGE = 1;  protected static final int LM_SLC_LEVELBITS = 3;  protected static final int LM_SLC_ACK = 128;  protected static final int LM_SLC_FLUSHIN = 64;  protected static final int LM_SLC_FLUSHOUT = 32;  protected static final int LM_SLC_SYNCH = 1;  protected static final int LM_SLC_BRK = 2;  protected static final int LM_SLC_IP = 3;  protected static final int LM_SLC_AO = 4;  protected static final int LM_SLC_AYT = 5;  protected static final int LM_SLC_EOR = 6;  protected static final int LM_SLC_ABORT = 7;  protected static final int LM_SLC_EOF = 8;  protected static final int LM_SLC_SUSP = 9;  /**   * Telnet Option: Environment   */  protected static final int NEWENV = 39;  protected static final int NE_INFO = 2;  protected static final int NE_VAR = 0;  protected static final int NE_VALUE = 1;  protected static final int NE_ESC = 2;  protected static final int NE_USERVAR = 3;  protected static final int NE_VAR_OK = 2;  protected static final int NE_VAR_DEFINED = 1;  protected static final int NE_VAR_DEFINED_EMPTY = 0;  protected static final int NE_VAR_UNDEFINED = -1;  protected static final int NE_IN_ERROR = -2;  protected static final int NE_IN_END = -3;  protected static final int NE_VAR_NAME_MAXLENGTH = 50;  protected static final int NE_VAR_VALUE_MAXLENGTH = 1000;  /**   * The following options are options which might be of interest, but are not   * yet implemented or in use.   */  /**   * Unused   */  protected static final int EXT_ASCII = 17;		//Defines Extended ASCII  protected static final int SEND_LOC = 23;		//Defines Send Location  protected static final int AUTHENTICATION = 37;	//Defines Authentication  protected static final int ENCRYPT = 38;			//Defines Encryption  /**   * Window Size Constants   */  private static final int SMALLEST_BELIEVABLE_WIDTH = 20;  private static final int SMALLEST_BELIEVABLE_HEIGHT = 6;  private static final int DEFAULT_WIDTH = 80;  private static final int DEFAULT_HEIGHT = 25;  /** end Constants declaration **************************************************/}//class TelnetIO

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -