当前位置: 首页>>代码示例>>C++>>正文


C++ ACE_Name_Request::decode方法代码示例

本文整理汇总了C++中ACE_Name_Request::decode方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Name_Request::decode方法的具体用法?C++ ACE_Name_Request::decode怎么用?C++ ACE_Name_Request::decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ACE_Name_Request的用法示例。


在下文中一共展示了ACE_Name_Request::decode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sizeof

int
ACE_Name_Proxy::recv_reply (ACE_Name_Request &reply)
{
  ACE_TRACE ("ACE_Name_Proxy::recv_reply");
  // Read the first 4 bytes to get the length of the message This
  // implementation assumes that the first 4 bytes are the length of
  // the message.
  ssize_t n = this->peer_.recv ((void *) &reply, sizeof (ACE_UINT32));

  switch (n)
    {
    case -1:
      // FALLTHROUGH
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("****************** recv_reply returned -1\n")));
    default:
      ACE_ERROR ((LM_ERROR,
                  ACE_TEXT ("%p got %d bytes, expected %d bytes\n"),
                  ACE_TEXT ("recv failed"),
                  n,
                  sizeof (ACE_UINT32)));
      // FALLTHROUGH
    case 0:
      // We've shutdown unexpectedly
      return -1;
      // NOTREACHED
    case sizeof (ACE_UINT32):
      {
        // Transform the length into host byte order.
        ssize_t length = ACE_NTOHL (reply.length ());

        // Receive the rest of the request message.
        // @@ beware of blocking read!!!.
        n = this->peer_.recv ((void *) (((char *) &reply)
                                        + sizeof (ACE_UINT32)),
                              length - sizeof (ACE_UINT32));

        // Subtract off the size of the part we skipped over...
        if (n != ssize_t (length - sizeof (ACE_UINT32)))
          {
            ACE_ERROR ((LM_ERROR,
                        ACE_TEXT ("%p expected %d, got %d\n"),
                        ACE_TEXT ("invalid length"),
                        length,
                        n));
            return -1;
          }

        // Decode the request into host byte order.
        if (reply.decode () == -1)
          {
            ACE_ERROR ((LM_ERROR,
                        ACE_TEXT ("%p\n"),
                        ACE_TEXT ("decode failed")));
            return -1;
          }
      }
    }
  return 0;
}
开发者ID:1ATOM,项目名称:mangos,代码行数:60,代码来源:Name_Proxy.cpp


注:本文中的ACE_Name_Request::decode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。