#ifndef TCPSOCKET_H #define TCPSOCKET_H #include #include class TcpSocket : public QTcpSocket { Q_OBJECT public: explicit TcpSocket(QObject *parent = nullptr); bool waitForConnected(int msecs = 30000) override; bool waitForDisconnected(int msecs = 30000) override; bool waitForBytesWritten(int msecs = 30000) override; bool waitForReadyRead(int msecs = 30000) override; qint64 readData(char *data, qint64 maxlen) override; qint64 readLineData(char *data, qint64 maxlen) override; qint64 writeData(const char *data, qint64 len) override; bool hasErr = false; bool isWritten = false; bool isReadyRead = false; private: std::mutex mtx; std::condition_variable cv; }; #endif // TCPSOCKET_H