Files
checker_host/interface/if_tcp.h

49 lines
916 B
C
Raw Normal View History

2023-11-21 20:28:23 +08:00
#ifndef IF_TCP_H
#define IF_TCP_H
#include <QObject>
#include <interface/interface.h>
2023-11-26 23:05:35 +08:00
#include "QTimer"
#include <QNetworkInterface>
#include <QTcpSocket>
#include <QObject>
#include <QThread>
#include <QTimer>
#include "QByteArray"
#include "base/mycfg.h"
2023-11-21 20:28:23 +08:00
class if_tcp : public InterFace
{
Q_OBJECT
public:
if_tcp();
virtual ~if_tcp();
2023-11-26 23:05:35 +08:00
void init();
int write(myarray data);
protected:
QString get_local_ip();
2023-11-21 20:28:23 +08:00
2023-11-26 23:05:35 +08:00
protected slots:
void reconnect_cb();
void connected_cb();
void disconnected_cb();
void state_changed_cb(QAbstractSocket::SocketState nSocketState);
void on_error_cb(QAbstractSocket::SocketError nErrCode);
void ready_read_cb();
signals:
void tcp_connected_signal();
2023-11-21 20:28:23 +08:00
protected:
2023-11-26 23:05:35 +08:00
mycfg *cfg_;
QTimer *timer_reconnect_;
int reconnect_timeout_ms;
QTcpSocket *tcp_socket_;
bool connect_state;
QTimer *timer_recv_end_;
int recv_end_timeout_ms;
2023-11-21 20:28:23 +08:00
};
#endif // IF_TCP_H