[Ace-users] How can I make such a Message_Block

kun niu haoniukun at gmail.com
Mon Dec 3 03:41:48 CST 2007

Hi all,

I'm trying to make my program make use of ACE_Message_Block.
My client is not written with ACE.
And it sends me the message like this:
the first four bytes represent the length of the following text
message in network byte order(big endian) and including the '\0'
following these bytes, I'll get my real message in clear text.
For example, my message might look like this:
00 00 00 06 'h' 'e' 'l' 'l' 'o' '\0'
And I want to pack them into an ACE_Message_Block.
So I used the constructor ACE_Message_Block block(buffer, length)
Then I have the following code:
ACE_InputCDR cdr(&block);
ACE_CDR::ULong str_length;
char str_buffer[1024];
cdr.read_char_array(str_buffer, bytes_received-4);

But I found that the output are all wrong.
Would anyone please help me to solve the problem?

Any help would be appreciated and thanks in advance.

More information about the Ace-users mailing list