|
// lunwentest.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "ace/Message_Queue.h"
#include "ace/Asynch_IO.h"
#include "ace/OS.h"
#include "ace/Proactor.h"
#include "ace/Asynch_Acceptor.h"
class HA_Proactive_Service : public ACE_Service_Handler
{
public:
~HA_Proactive_Service ()
{
if (this->handle () != ACE_INVALID_HANDLE)
ACE_OS::closesocket (this->handle ());
}
virtual void open (ACE_HANDLE h, ACE_Message_Block&)
{
this->handle (h);
if (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 = new ACE_Message_Block(buffer,1024);
if (this->reader_.read (*mb, mb->space ()) != 0)
{
ACE_OS::printf("Begin read fail\n");
delete this;
return;
}
return;
}
virtual void handle_read_stream
(const ACE_Asynch_Read_Stream::Result &result)
{
ACE_Message_Block &mb = result.message_block ();
if (!result.success () || result.bytes_transferred () == 0)
{
mb.release ();
delete this;
return;
}
mb.copy(""); //为字符串添加结束标记'\0'
ACE_OS::printf("rev:\t%s\n",mb.rd_ptr());
mb.release();
ACE_Message_Block *nmb = new ACE_Message_Block(buffer,1024);
if (this->reader_.read (*nmb, nmb->space ()) != 0)
return;
}
private:
ACE_Asynch_Read_Stream reader_;
char buffer[1024];
};
int main(int argc, char *argv[])
{
int port=3000;
ACE_Asynch_Acceptor<HA_Proactive_Service> acceptor;
if (acceptor.open (ACE_INET_Addr (port)) == -1)
return -1;
while(true)
ACE_Proactor::instance ()->handle_events ();
return 0;
}
------ 已启动生成: 项目: lunwentest, 配置: Debug Win32 ------
正在编译...
lunwentest.cpp
f:\ace-5.7.7\ace_wrappers\ace\framework_component.h(191) : error C2146: syntax error : missing ';' before identifier 'shutting_down_'
f:\ace-5.7.7\ace_wrappers\ace\framework_component.h(191) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
f:\ace-5.7.7\ace_wrappers\ace\framework_component.h(191) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
f:\ace-5.7.7\ace_wrappers\ace\framework_component.h(191) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
f:\ace-5.7.7\ace_wrappers\ace\proactor.h(623) : error C2146: syntax error : missing ';' before identifier 'end_event_loop_'
f:\ace-5.7.7\ace_wrappers\ace\proactor.h(623) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
f:\ace-5.7.7\ace_wrappers\ace\proactor.h(623) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
f:\ace-5.7.7\ace_wrappers\ace\proactor.h(626) : error C2146: syntax error : missing ';' before identifier 'event_loop_thread_count_'
f:\ace-5.7.7\ace_wrappers\ace\proactor.h(626) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
f:\ace-5.7.7\ace_wrappers\ace\proactor.h(626) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
生成日志保存在“file://d:\aceex\lunwentest\lunwentest\Debug\BuildLog.htm”
lunwentest - 10 个错误,0 个警告
========== 生成: 0 已成功, 1 已失败, 0 最新, 0 已跳过 ========== |
|