ACE_Mesaage_Block,ACE_InputCdr,ACE_OutputCdr的使用
2016-01-01 11:55
681 查看
The ACE_Message_Block class enables efficient manipulation of fixed- and variable-sized messages. ACE_Message_Block implements the Composite pattern [GHJV95] and provides the following capabilities: Each ACE_Message_Block contains a pointer to a reference-counted ACE_Data_Block, which in turn points to the actual data associated with a message. This design allows flexible and efficient sharing of data and minimizes excessive memory copying overhead. It allows multiple messages to be chained together into a singly linked list to support composite messages, which can be used for polymorphic lists and for layered protocol stacks that require headers/trailers to be inserted/removed efficiently. It allows multiple messages to be joined together in a doubly linked list that forms the basis of the ACE_Message_Queue class outlined on page 228 and described in [SH]. It treats synchronization and memory management properties as aspects [Kic97, CE00] that applications can vary without changing the underlying ACE_Message_Block implementation. The ACE_Message_Block Class Diagram 照片名称:Two Kinds of ACE_Message_Block ACE_Message_Block 一般和 ACE_InputCdr,ACE_outputCdr 结合使用,以下是使用的一些方法: //mb = new ACE_Message_Block(); //ACE_CDR::mb_align(mb); /*ACE_OutputCDR cdr(mb->wr_ptr(),ACE_CDR::MAX_ALIGNMENT+8);*/ //这种方法不对 ACE_OutputCDR cdr(ACE_CDR::MAX_ALIGNMENT+8); size_t length1 = cdr.length(); ACE_Message_Block * mb = NULL; mb = new ACE_Message_Block(cdr.begin()->rd_ptr(),cdr.begin()->total_length()); ACE_ASSERT(cdr.begin()->rd_ptr() == cdr.begin()->wr_ptr() ); cdr << ACE_CDR::Long(22); cdr << ACE_CDR::Long(22); size_t length2 = cdr.length(); /*mb->wr_ptr((cdr.begin())->total_length());*/ mb->wr_ptr(length2 - length1); // wr_ptr指针要往前移动 length2 - length1个字节,ACE_OutputCDR 不会去更新wr_ptr,只能手工更新 ACE_Message_Block * payload = NULL; payload = new ACE_Message_Block("11111"); //申请另外一个 ACE_Message_Block payload->rd_ptr(5); payload->wr_ptr(10); mb->cont(payload); //形成ACE_Message_Block链表 ACE_InputCDR 的使用 ACE_Message_Block * mb = new ACE_Message_Block (ACE_DEFAULT_CDR_BUFSIZE); if(sock_.recv_n(mb->wr_ptr(),8) == 8) { mb->wr_ptr(8); ACE_InputCDR cdr(mb); ACE_CDR::Long Type,Type1; cdr >> Type; cdr >>Type1; if(sock_.recv_n(mb->wr_ptr(),3) > 0) { mb->wr_ptr(3); } 关于ACE_Message_block ,ACE_Inputcdr,ACE_OutputCdr的使用的注意事项还有很多,需要一步一步发掘。 |
相关文章推荐
- 详解基于Bootstrap扁平化的后台框架Ace
- ACE反应器(Reactor)模式的深入分析
- 值得分享的Bootstrap Ace模板实现菜单和Tab页效果
- Leanote集成Ace代码编辑器, 程序员的最爱
- 【原创】基于ACE Proactor框架下高并发、大容量吞吐程序设计既最近的一个产品开发总结
- Ace 1.3.1 网站管理后台源码 Bootstrap响应式模板主题
- WIN7+VS2010 ACE配置
- ACE编译与安装
- Centos 编译安装ACE
- bootstrap ace admin 整合java HTML5 全新高大尚后台框架
- aceadmin源码
- Java全新高大尚HTML5 bootstrap ace后台框架源码springmvc mybatis(oracle 和 mysql)
- windows下ACE怎样安装与使用说明?
- ACE Reactor FrameWork使用注意事项
- ACE:多线程简介
- ACE的安装
- bootstrap ace admin 整合java HTML5 全新高大尚后台框架
- ACE在Windows下的简单编译过程
- ACE和TAO编译时支持Unicode字符集和Qt
- 关于ACE_Asynch_Acceptor::accept 内存泄露的问题(Windows)