forked from lyq/smart-greenhouse
42 lines
694 B
C++
42 lines
694 B
C++
#ifndef CNETWORKUTIL_H
|
|
#define CNETWORKUTIL_H
|
|
|
|
#include <QMainWindow>
|
|
#include <QObject>
|
|
#include <QWidget>
|
|
|
|
#include <QTcpSocket> //
|
|
#include <QHostAddress> //地址格式
|
|
#include <QDebug>
|
|
|
|
|
|
class CNetWorkUtil
|
|
{
|
|
//Q_OBJECT
|
|
|
|
private:
|
|
QTcpSocket m_tcpSocket;
|
|
int m_port = 8080;
|
|
QString m_ip = "127.0.0.1";
|
|
|
|
|
|
public:
|
|
CNetWorkUtil();
|
|
void connect();
|
|
void connect(QString ip,int port);
|
|
void setIp(QString ip);
|
|
QString getIp();
|
|
void setPort(int port);
|
|
int getPort();
|
|
bool isConnected();
|
|
void disconnect();
|
|
QTcpSocket & getTcpSocket();
|
|
void sendMsg(QString msg);
|
|
|
|
};
|
|
|
|
|
|
extern CNetWorkUtil *networkUtil;
|
|
|
|
#endif // CNETWORKUTIL_H
|