-
Notifications
You must be signed in to change notification settings - Fork 1
/
ctcpsock.h
41 lines (35 loc) · 1.15 KB
/
ctcpsock.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef CTCPSOCKCLIENT_H
#define CTCPSOCKCLIENT_H
#include <QObject>
#include <QTcpSocket>
#include <QByteArray>
#include <QList>
//TCP client 模块
class CTcpSock : public QObject
{
Q_OBJECT
public:
explicit CTcpSock(QObject *parent = 0);
private:
QTcpSocket *m_pSock;
private: //内部信号处理
void on_sockConnected();
void on_sockDisconnected();
void on_sockReceived();
private slots:
void on_error(QAbstractSocket::SocketError socketError);
signals:
void sig_recvData(const QByteArray &array); //接收到数据
void sig_sockConneted(qint8 res); // 连接结果 1:OK 0:失败
void sig_sockConnected(); // 以建立连接
void sig_sockDisconnected(); // 已断开连接
void sig_sockError(QAbstractSocket::SocketError socketError); //sock报错
void sig_Debug(QString info);
public:
bool connectSocket(QString strIP,quint16 nPort,int msecs);
void disconnectSocket(); //断开连接
QAbstractSocket::SocketState stateSock(); //连接状态
void sendSockData(QByteArray &array); //发送流式数据
void connectSocket(QString strIP,quint16 nPort); //连接
};
#endif // CTCPSOCKCLIENT_H