ACE_Dev_Poll_Reactor,handle_output问题
各位大侠,我在使用ACE_Dev_Poll_Reactor的时候,同时注册READ_MASK和WRITE_MASK但是发现handle_output()函数被狂调,当客户端向服务器发送请求时,handle_input却没有反映,这是怎么回事呢?部分代码如下:class Mirror : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_MT_SYNCH>
int Mirror::open(void *) {
//这里Reactor为epoll模型:
ACE_Reactor::instance()->register_handler(this, ACE_Event_Handler::READ_MASK);
//导致handle_output被狂调,而当客户端有输入时,handle_input却没有反映
ACE_Reactor::instance()->register_handler(this, ACE_Event_Handler::WRITE_MASK);
return 0;
}
R u sure socket server is opened properly?
Why do you need output mask for socket server?
Can u comment out WRITE_MASK and try again?
Almost certain you did something wrong.(:D 当服务器往客户端发送数据时,我想使用WRITE_MASK,如果不使用WRITE_MASK难道直接将数据send出去吗,还是用别的方法检测socket是否可写? You don't need WRITE_MASK to send data.
sned_n/send/write... will give you error if something wrong. 现在我是这么做的,如果buffer中有内容,则注册WRITE_MASK,如果buffer中的数据都被发送了,则将WRITE_MASK注销,但是我发现如果调用:
ACE_Reactor::instance()->remove_handler(peer().get_handle(), ACE_Event_Handler::WRITE_MASK );会把当前的SVC_Handler对象析构掉
如果改成:
ACE_Reactor::instance()->remove_handler(peer().get_handle(), ACE_Event_Handler::WRITE_MASK|ACE_Event_Handler::DONT_CALL);
则不会将当前SVC_handler对象析构。运行正常
页:
[1]