bolar_1 date 2026-7-1 d:/proc

This commit is contained in:
2026-11-27 17:44:38 +08:00
commit 0dbdfa57bc
890 changed files with 325428 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
#ifndef TCP_H
#define TCP_H
#include <string>
#include <functional>
class Tcp {
public:
virtual ~Tcp() = default;
virtual bool Connect(const std::string& host, int port) = 0;
virtual void Disconnect() = 0;
virtual int Send(const std::string& data) = 0;
virtual void OnStream(std::function<void(const std::string& data)> callback) {
stream_callback_ = callback;
}
virtual void OnDisconnected(std::function<void()> callback) {
disconnect_callback_ = callback;
}
// 连接状态查询
bool connected() const { return connected_; }
protected:
std::function<void(const std::string& data)> stream_callback_;
std::function<void()> disconnect_callback_;
// 连接状态管理
bool connected_ = false; // 是否可以正常读写数据
};
#endif // TCP_H