36 STATE_IACSB = (char)2,
37 STATE_IACWILL = (
char)3,
38 STATE_IACDO = (char)4,
39 STATE_IACWONT = (
char)5,
40 STATE_IACDONT = (char)6,
41 STATE_IACSBIAC = (
char)7,
42 STATE_IACSBDATA = (char)8,
43 STATE_IACSBDATAIAC = (
char)9,
44 STATE_DATAR = (char)10,
45 STATE_DATAN = (
char)11
60 TELOPT_BINARY = (char)0,
61 TELOPT_ECHO = (
char)1,
63 TELOPT_EOR = (
char)25,
64 TELOPT_NAWS = (char)31,
65 TELOPT_TTYPE = (
char)24
70 TELQUAL_SEND = (
char)1
74 QTcpSocket m_tcpSocket;
75 QWebSocket m_webSocket;
76 SocketType m_socketType;
77 static const char IACWILL[2];
78 static const char IACWONT[2];
79 static const char IACDO[2];
80 static const char IACDONT[2];
81 static const char IACSB[2];
82 static const char IACSE[2];
83 static char _sendCodeArray[2];
84 static char _arrCRLF[2];
85 static char _arrCR[2];
89 enum TelnetStateCodes m_negotiationState;
90 char m_receivedDX[256];
91 char m_receivedWX[256];
96 char m_buffIncoming[IncommingBufferSize];
97 char m_buffProcessed[IncommingBufferSize];
101 void emitEndOfRecord() { emit endOfRecord(); }
102 void emitEchoLocal(
bool bEcho) { emit echoLocal(bEcho); }
104 void sendTelnetControl(
char codigo);
106 void transpose(
const char *buf,
int iLen);
108 void willsReply(
char action,
char reply);
109 void wontsReply(
char action,
char reply);
110 void doesReply(
char action,
char reply);
111 void dontsReply(
char action,
char reply);
113 void sendSB(
char code,
char *arr,
int iLen);
114 qint64 doTelnetInProtocol(qint64 buffSize);
117 explicit QTelnet(SocketType type = TCP, QObject *parent = 0);
120 void setType(SocketType type);
121 void connectToHost(
const QString &hostName, quint16 port);
122 void disconnectFromHost(
void);
123 void sendData(
const QByteArray &ba);
124 void sendData(
const char *data,
int len);
125 void setCustomCRLF(
char lf = 13,
char cr = 10);
126 void setCustomCR(
char cr = 10,
char cr2 = 0);
128 void writeCustomCRLF();
129 void writeCustomCR();
131 void write(
const char c);
132 qint64 write(
const char *data, qint64 len);
133 qint64 read(
char *data, qint64 maxlen);
135 bool isConnected()
const;
136 bool testBinaryMode()
const;
137 void setWindSize(QSize s) {m_winSize = s;}
138 void sendWindowSize();
140 QString peerInfo()
const;
141 QString peerName()
const;
143 QString errorString();
146 void newData(
const char *buff,
int len);
148 void echoLocal(
bool echo);
149 void stateChanged(QAbstractSocket::SocketState s);
150 void error(QAbstractSocket::SocketError err);
153 void socketError(QAbstractSocket::SocketError err);
154 void onTcpReadyRead();
155 void binaryMessageReceived(
const QByteArray &message);
156 void onStateChanged(QAbstractSocket::SocketState s);