using System; using System.Text; using System.Net.Sockets; /// <summary> /// Summary description for ClassTelnet /// </summary> public class ClassTelnet { TcpClient telnet_tcp_client; public string strhost; // IP 地址 public string strusername; // username public string strpassword; // password private int ilogin_wait_time = 200; //网络延迟等待时间 private int irecv_wait_time = 100; //网络延迟等待时间 //Telnet protocal key enum Verbs { WILL = 251, WONT = 252, DO = 253, DONT = 254, IAC = 255 } public ClassTelnet() { } /** * Telnet 关闭连接 */ public void close_telnet() { try { if (telnet_tcp_client == null) { return; } if (telnet_tcp_client.Connected) { telnet_tcp_client.Close(); } } catch (Exception ex) { Consule.Write("异常"); } } /** * Telnet连接到服务器 */ public bool open_connect() { bool blresult; string strtemp; blresult = true; try { // new socket telnet_tcp_client = new TcpClient(this.strhost, 23); System.Threading.Thread.Sleep(ilogin_wait_time); // read host info data strtemp = recv_data_from_host(); blresult = strtemp.TrimEnd().EndsWith(":"); i