|
通过ace的connector建立与多个server的连接,如何保证非阻塞?
从他的论文集看到段代码,不知道怎么用?而且对于PEER_CONNECTOR,和HANDLE属于那个头文件?
template <class SERVICE_HANDLER,class PEER_CONNECTOR>
class AsyConnector:public Event_Handler
{
public:
AsyConnector(void);
~AsyConnector(void);
enum Connect_Mode
{
SYNC, //以同步方式连接
ASYNC //以异步方式连接
};
// 主动连接并激活服务处理器
int connect (SERVICE_HANDLER *sh,
const PEER_CONNECTOR::PEER_ADDR &addr,
Connect_Mode mode);
protected:
//定义连接激活策略
virtual int connect_service_handler(SERVICE_HANDLER *sh,
const PEER_CONNECTOR::PEER_ADDR &addr,
Connect_Mode mode);
// Defines the handler's concurrency strategy.
virtual int activate_service_handler(SERVICE_HANDLER *sh);
// 当以异步方式连接完成时激活服务处理器
virtual int complete (HANDLE handle);
//以下方法不是必须
int register_handler(SERVICE_HANDLER* sh,Connect_Mode mode);
private:
// IPC mechanism that establishes
// connections actively.
PEER_CONNECTOR connector_;
Map_Manager<HANDLE, SERVICE_HANDLER *> handler_map_;
virtual int handle_event(HANDLE handle,EVENT_TYPE type);
};
这里先谢过 |
|