Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / ACE / examples / Service_Configurator / IPC-tests / server / Handle_L_Pipe.cpp
blob53c48b7f8225eb721504ca18dec3f413708d94f3
1 #include "Handle_L_Pipe.h"
2 #include "ace/OS_NS_ctype.h"
3 #include "ace/OS_NS_unistd.h"
5 #if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS)
7 // Uppercase N bytes of S.
9 char *
10 Handle_L_Pipe::upper_case (char s[], int n)
12 while (--n >= 0)
13 if (ACE_OS::ace_islower (s[n]))
14 s[n] = ACE_OS::ace_toupper (s[n]);
16 return s;
19 int
20 Handle_L_Pipe::handle_input (ACE_HANDLE)
22 ACE_LSOCK_Stream new_local_stream;
23 int n;
24 ACE_HANDLE fd1 = ACE_INVALID_HANDLE;
25 ACE_HANDLE fd2 = ACE_INVALID_HANDLE;
26 char buf[BUFSIZ];
28 if (this->accept (new_local_stream) == -1)
29 return -1;
31 if (new_local_stream.recv_handle (fd1) == -1
32 || new_local_stream.recv_handle (fd2) == -1)
33 return -1;
34 else
35 ACE_DEBUG ((LM_INFO,
36 ACE_TEXT ("received file descriptors %d and %d\n"),
37 fd1,
38 fd2));
40 if ((n = ACE_OS::read (fd1, buf, sizeof buf)) == -1)
41 return -1;
42 else if (ACE_OS::write (fd2, this->upper_case (buf, n), n) == -1)
43 return -1;
44 if (ACE_OS::close (fd1) == -1
45 || ACE_OS::close (fd2) == -1)
46 return -1;
47 if (new_local_stream.close () == -1)
48 return -1;
50 return 0;
53 const ACE_TCHAR *Handle_L_Pipe::DEFAULT_RENDEZVOUS = ACE_TEXT ("/tmp/foo_pipe");
55 #if !defined (__ACE_INLINE__)
56 #include "Handle_L_Pipe.inl"
57 #endif /* __ACE_INLINE__ */
59 Handle_L_Pipe local_pipe;
60 ACE_Service_Object_Type lp (&local_pipe, ACE_TEXT ("Local_Pipe"));
62 #endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */