Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / ACE / examples / APG / Threads / Message_Blocks.cpp
blob13e2c54b0ed52bf74e54265b1a0ee0a3ab0dfa7f
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 **)
10 #if 0
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);
19 // Listing 1
20 #endif /* 0 */
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);
30 // Listing 2
31 // Listing 3 code/ch12
32 ACE_DEBUG((LM_DEBUG,
33 ACE_TEXT ("Command Sequence --> %C\n"),
34 mb->rd_ptr ()));
35 mb->rd_ptr (ACE_OS::strlen (mb->rd_ptr ())+1);
36 mb->release ();
37 // Listing 3
38 // Listing 4 code/ch12
39 // Send a hangup notification to the receiver.
40 ACE_NEW_RETURN
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);
44 // Listing 4
45 mb->release ();
47 return 0;