本文整理汇总了C++中ACE_InputCDR::byte_order方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_InputCDR::byte_order方法的具体用法?C++ ACE_InputCDR::byte_order怎么用?C++ ACE_InputCDR::byte_order使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_InputCDR
的用法示例。
在下文中一共展示了ACE_InputCDR::byte_order方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handle_input
//.........这里部分代码省略.........
ssize_t retcode = stream.recv_n (header.wr_ptr (), header_size);
if (retcode != header_size)
ACE_ERROR_RETURN ((LM_ERROR,
"%T (%t) - %M - invalid TCP/IP header\n"),
-1);
// Reflect the number of bytes read from the stream.
header.wr_ptr (header_size);
// Extract the header from the message block.
CUTS_TCPIP_SPEC spec;
ACE_CDR::ULong datasize;
ACE_InputCDR input (header.rd_ptr (), header_size);
// Read the SPEC and the datasize from the packet.
input >> spec;
input >> datasize;
if (!input.good_bit ())
ACE_ERROR_RETURN ((LM_ERROR,
"%T (%t) - %M - failed to read TCP/IP header\n"),
-1);
// Construct a chain of message blocks to read the payload associated
// with the received event.
ACE_Message_Block * mb = 0;
ACE_NEW_RETURN (mb, ACE_Message_Block (ACE_CDR::DEFAULT_BUFSIZE), -1);
ssize_t read_count;
ACE_Message_Block * head = mb;
ACE_Auto_Ptr <ACE_Message_Block> auto_clean (head);
for (size_t remaining = datasize; 0 != remaining; )
{
// Determine how much should be read in this attempt.
read_count =
ACE_CDR::DEFAULT_BUFSIZE < remaining ?
ACE_CDR::DEFAULT_BUFSIZE : remaining;
// Read the data from the stream.
retcode = stream.recv_n (mb->wr_ptr (), read_count);
if (retcode != read_count)
ACE_ERROR_RETURN ((LM_ERROR,
"%T - %M - %m\n"),
-1);
// Substract the amount from the remaining count.
mb->wr_ptr (read_count);
remaining -= read_count;
if (0 != remaining)
{
// Allocate a new block for the chain.
ACE_Message_Block * temp = 0;
ACE_NEW_RETURN (temp,
ACE_Message_Block (ACE_CDR::DEFAULT_BUFSIZE),
-1);
// Insert new block in the chain and move forward.
mb->cont (temp);
mb = temp;
}
}
// Since we have made it this far, we have successfully read the
// event and its payload from the socket. Now, pass the message
// the object manger, so it can dispatch it accordingly.
if (this->obj_mgr_ != 0)
{
iCCM::TCPIP_Servant * svnt = 0;
int retval = this->obj_mgr_->find_object (spec.uuid_, svnt);
if (0 == retval)
{
// Signal the object to handle the event.
ACE_InputCDR ev (head, input.byte_order ());
retval = svnt->handle_event (spec.event_id_, ev);
if (-1 == retval)
ACE_ERROR ((LM_ERROR,
"%T (%t) - %M - failed to handle event [%s]\n",
spec.uuid_.to_string ()->c_str ()));
}
else
ACE_ERROR ((LM_ERROR,
"%T (%t) - %M - failed to locate object with id [%s]\n",
spec.uuid_.to_string ()->c_str ()));
}
// Release the message block.
// head->release ();
return 0;
}