#ifndef _TCPSERVER_H_ #define _TCPSERVER_H_ #include class TcpServer : public QTcpServer { Q_OBJECT public: explicit TcpServer(QObject *parent = nullptr); ~TcpServer() override; /* 启动服务器 */ bool startServer(quint16 port); /* 停止服务器 */ void stopServer(); private slots: /* 接收监听信息 */ void do_newConnection(); /* 处理客户端断开连接 */ void do_clientDisconnected(); /* 接收消息 */ void do_readyRead(); /* 发送消息 */ void do_sendMessage(QTcpSocket* pSocket, const QByteArray& message); private: private: std::list m_listClients; /* 客户端列表 */ }; #endif // _TCPSERVER_H_