📄 tcpclient.h
字号:
#ifndef INCLUDED_TCPCLIENT_H
#define INCLUDED_TCPCLIENT_H
#if defined(HAS_PRAGMA_ONCE)
#pragma PRAGMA_ONCE_DECLARE
#endif
#include "socketex.h"
#include "patterns/util/logcontrol.h"
namespace acl
{
class TcpClient : public CTThreadExtend
, public stk::LogControl
{
public:
TcpClient();
TcpClient(u_short port, const char *addr);
virtual ~TcpClient();
//start the service
bool start();
bool start(u_short port, const char *addr);
//stop the service
void stop(int timeout = INFINITE);
//main interface for user call :
int send(const char *buf, int buf_size);
bool connected() { return m_comm.isConnected(); }
DWORD getError() { return m_comm.getError(); }
private:
bool connect();
bool connect(const SocketAddress &address);
virtual void threadProcess();
void handleBroken();
virtual void onConnected() { }
virtual void onBroken() { }
virtual int onReceive() = 0;
protected:
ClientSocket m_comm; // communication component
private:
volatile bool m_exit_signaled;
bool m_alive;
int m_reconnectInterval;
enum
{
RECONNECT_INTERVAL = 3000, // reconnect timer interval
};
};
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -