1 #include "ace/SPIPE_Addr.h"
2 #include "ace/SPIPE_Acceptor.h"
3 #include "ace/Log_Msg.h"
4 #include "ace/OS_NS_stdio.h"
5 #include "ace/OS_NS_unistd.h"
8 #if defined (ACE_WIN32)
9 #define MAKE_PIPE_NAME(X) ACE_TEXT ("\\\\.\\pipe\\") ACE_TEXT (X)
11 #define MAKE_PIPE_NAME(X) ACE_TEXT (X)
15 ACE_TMAIN (int /* argc */, ACE_TCHAR
* /* argv */ [])
17 ACE_SPIPE_Acceptor acceptor
;
18 ACE_SPIPE_Stream new_stream
;
21 const ACE_TCHAR
*rendezvous
= MAKE_PIPE_NAME ("acepipe");
23 // Initialize named pipe listener.
25 if (acceptor
.open (ACE_SPIPE_Addr (rendezvous
)) == -1)
26 ACE_ERROR_RETURN ((LM_ERROR
,
28 ACE_TEXT ("open")), 1);
33 ACE_TEXT ("waiting for connection\n")));
35 // Accept a client connection.
36 if (acceptor
.accept (new_stream
, 0) == -1)
37 ACE_ERROR_RETURN ((LM_ERROR
,
43 ACE_TEXT ("Accepted connection\n")));
45 while ((n
= new_stream
.recv (buf
, sizeof buf
)) > 0)
47 ACE_OS::fprintf (stderr
,
50 ACE_OS::write (ACE_STDOUT
,
58 ACE_TEXT ("End of connection. Closing handle\n")));
63 ACE_NOTREACHED(return 0);