1 #include "ace/OS_main.h"
2 #include "ace/OS_Memory.h"
3 #include "ace/OS_NS_stdio.h"
4 #include "ace/OS_NS_string.h"
5 #include "ace/Log_Msg.h"
6 #include "ace/Message_Block.h"
8 int ACE_TMAIN (int, ACE_TCHAR
**)
11 // Just for the book...
13 // Listing 1 code/ch12
14 ACE_Message_Block
*mb
= 0;
15 ACE_NEW_RETURN (mb
, ACE_Message_Block (128), -1);
17 const char *deviceAddr
= "Dev#12";
18 mb
->copy (deviceAddr
, ACE_OS::strlen (deviceAddr
)+1);
21 // Listing 2 code/ch12
22 ACE_Message_Block
*mb
= 0;
23 ACE_NEW_RETURN (mb
, ACE_Message_Block (128), -1);
25 const char *commandSeq
= "CommandSeq#14";
26 ACE_OS::sprintf (mb
->wr_ptr (), "%s", commandSeq
);
27 // Move the wr_ptr() forward in the buffer by the
28 // amount of data we just put in.
29 mb
->wr_ptr (ACE_OS::strlen (commandSeq
) +1);
31 // Listing 3 code/ch12
33 ACE_TEXT ("Command Sequence --> %C\n"),
35 mb
->rd_ptr (ACE_OS::strlen (mb
->rd_ptr ())+1);
38 // Listing 4 code/ch12
39 // Send a hangup notification to the receiver.
41 (mb
, ACE_Message_Block (128, ACE_Message_Block::MB_HANGUP
), -1);
42 // Send an error notification to the receiver.
43 mb
->msg_type (ACE_Message_Block::MB_ERROR
);