|
楼主 |
发表于 2009-10-12 11:15:57
|
显示全部楼层
回复 #2 winston 的帖子
class HA_Proactive_Service : public ACE_Service_Handler
{
public:
~HA_Proactive_Service ()
{
if (this->handle () != ACE_INVALID_HANDLE)
{
this->reader_.cancel();
this->writer_.cancel();
ACE_OS::shutdown(this->handle_, ACE_SHUTDOWN_WRITE);
ACE_OS::closesocket (this->handle ());
this->handle (ACE_INVALID_HANDLE);
}
}
virtual void open (ACE_HANDLE h, ACE_Message_Block&)
{
_cur[num] = this;
num++;
this->handle (h);
if (this->writer_.open (*this) != 0 ||this->reader_.open(*this) != 0)
{
ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"),
ACE_TEXT ("HA_Proactive_Service open")));
delete this;
return;
}
ACE_Message_Block *mb;
ACE_NEW_NORETURN(mb,ACE_Message_Block(1024));
if (this->reader_.read(*mb, mb->space ()) != 0)
{
ACE_OS::printf("Begin read fail\n");
mb->release();
delete this;
return;
}
}
下面就是读写的处理。。
private:
static HA_Proactive_Service *_cur[100];
ACE_Asynch_Read_Stream reader_;
ACE_Asynch_Write_Stream writer_;
};
HA_Proactive_Service *HA_Proactive_Service::_cur[100];
}
客户端和服务器的设置参考的http://www.acejoy.com/bbs/viewth ... &extra=page%3D6
错误的信息就是在关闭客户端的对话框时,服务器端弹出 “0x10053bea”指令引用的内存不能读的问题 |
|