Merge pull request #2317 from jwillemsen/jwi-deleteop
[ACE_TAO.git] / ACE / examples / IPC_SAP / SPIPE_SAP / producer_read.cpp
blobd16fc8d080c3f31e7712d8bb9cd735edddb8b89f
1 #include "ace/OS_main.h"
2 #include "ace/SPIPE_Addr.h"
3 #include "ace/SPIPE_Connector.h"
4 #include "ace/Log_Msg.h"
5 #include "ace/OS_NS_stdlib.h"
9 #if defined (ACE_HAS_STREAM_PIPES)
11 #include "shared.h"
13 const int DEFAULT_SIZE = 8 * 1024;
14 const int DEFAULT_COUNT = 100;
16 int
17 ACE_TMAIN (int argc, ACE_TCHAR *argv[])
19 int size = argc > 1 ? ACE_OS::atoi (argv[1]) : DEFAULT_SIZE;
20 int iterations = argc > 2 ? ACE_OS::atoi (argv[2]) : DEFAULT_COUNT;
21 char *buf = new char[size];
23 if (argc > 3)
24 rendezvous = argv[3];
26 ACE_SPIPE_Stream cli_stream;
27 ACE_SPIPE_Connector con;
28 int i;
30 if (con.connect (cli_stream, ACE_SPIPE_Addr (rendezvous)) == -1)
31 ACE_ERROR_RETURN ((LM_ERROR, "%p\n", rendezvous), -1);
33 for (i = 0; i < size; i++)
34 buf[i] = 'a';
36 for (i = 0; i < iterations; i++)
37 if (cli_stream.send (buf, size) != size)
38 ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "putmsg"), -1);
40 if (cli_stream.close () == -1)
41 ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), -1);
43 return 0;
45 #else
46 #include <stdio.h>
47 int ACE_TMAIN (int, ACE_TCHAR *[])
49 ACE_ERROR_RETURN ((LM_ERROR, "this feature is not supported"), -1);
51 #endif /* ACE_HAS_STREAM_PIPES */