summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>1996-11-01 08:40:32 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>1996-11-01 08:40:32 +0000
commit76171efcb983b4f2ff55a4013fed794f7a9bb471 (patch)
treea817b83efdc199c8f292b9a5bfd4047ef900f6b0 /examples
parentbad6c3a7b49b64377c60931084a6ef68ae64877b (diff)
downloadATCD-76171efcb983b4f2ff55a4013fed794f7a9bb471.tar.gz
foo
Diffstat (limited to 'examples')
-rw-r--r--examples/Connection/blocking/SPIPE-connector.cpp9
-rw-r--r--examples/Connection/non_blocking/CPP-acceptor.cpp2
-rw-r--r--examples/IPC_SAP/FIFO_SAP/FIFO-Msg-server.cpp4
-rw-r--r--examples/IPC_SAP/FIFO_SAP/FIFO-test.cpp17
-rw-r--r--examples/IPC_SAP/SOCK_SAP/FD-unclient.cpp17
-rw-r--r--examples/IPC_SAP/SOCK_SAP/FD-unserver.cpp27
6 files changed, 39 insertions, 37 deletions
diff --git a/examples/Connection/blocking/SPIPE-connector.cpp b/examples/Connection/blocking/SPIPE-connector.cpp
index 940f716433f..3bc22f1a280 100644
--- a/examples/Connection/blocking/SPIPE-connector.cpp
+++ b/examples/Connection/blocking/SPIPE-connector.cpp
@@ -30,7 +30,7 @@ Peer_Handler::open (void *)
if (ACE::register_stdin_handler (this,
ACE_Service_Config::reactor (),
ACE_Service_Config::thr_mgr ()) == -1)
- ACE_ERROR ((LM_ERROR, "%p\n", "register_stdin_handler"));
+ ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "register_stdin_handler"), -1);
}
else // If iterations_ has been set, send iterations_ buffers.
{
@@ -46,9 +46,8 @@ Peer_Handler::open (void *)
while (iterations_-- > 0
&& this->peer ().send_n (buffer, length) == length)
continue;
-
- return this->peer ().close ();
}
+ return this->peer ().close ();
}
int
@@ -93,8 +92,8 @@ Peer_Handler::display_menu (void)
}
IPC_Client::IPC_Client (void)
- : rendezvous_ ("acepipe"),
- iterations_ (0),
+ : iterations_ (0),
+ rendezvous_ ("acepipe"),
done_handler_ (ACE_Sig_Handler_Ex (ACE_Service_Config::end_proactor_event_loop))
{
}
diff --git a/examples/Connection/non_blocking/CPP-acceptor.cpp b/examples/Connection/non_blocking/CPP-acceptor.cpp
index e3c69ccfddc..e01586cc0d3 100644
--- a/examples/Connection/non_blocking/CPP-acceptor.cpp
+++ b/examples/Connection/non_blocking/CPP-acceptor.cpp
@@ -101,7 +101,7 @@ IPC_Server<SH, PR_AC_2>::init (int argc, char *argv[])
// Handle SIGPIPE signal through the ACE_Reactor.
else if (ACE_Service_Config::reactor ()->register_handler
(SIGPIPE, &this->done_handler_) == -1)
- ACE_ERROR ((LM_ERROR, "%p\n", "register_handler"));
+ ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "register_handler"), -1);
else
return 0;
}
diff --git a/examples/IPC_SAP/FIFO_SAP/FIFO-Msg-server.cpp b/examples/IPC_SAP/FIFO_SAP/FIFO-Msg-server.cpp
index 5af91f21afe..d4ffacd1171 100644
--- a/examples/IPC_SAP/FIFO_SAP/FIFO-Msg-server.cpp
+++ b/examples/IPC_SAP/FIFO_SAP/FIFO-Msg-server.cpp
@@ -12,7 +12,7 @@ main (int, char *[])
char buf[BUFSIZ];
ACE_Str_Buf msg (buf, 0, sizeof buf);
int flags = MSG_ANY;
- int band = 0;
+ int band = 0;
int n;
while ((n = server.recv (&band, &msg, (ACE_Str_Buf *) 0, &flags)) >= 0)
@@ -20,7 +20,7 @@ main (int, char *[])
if (msg.len == 0)
break;
else
- printf ("%4d (%4d): %*s", msg.len, band, msg.len, msg.buf);
+ ACE_DEBUG (("%4d (%4d): %*s", msg.len, band, msg.len, msg.buf));
flags = MSG_ANY;
band = 0;
}
diff --git a/examples/IPC_SAP/FIFO_SAP/FIFO-test.cpp b/examples/IPC_SAP/FIFO_SAP/FIFO-test.cpp
index 1cfae1dfd2f..cde046c26ea 100644
--- a/examples/IPC_SAP/FIFO_SAP/FIFO-test.cpp
+++ b/examples/IPC_SAP/FIFO_SAP/FIFO-test.cpp
@@ -1,9 +1,10 @@
-/* Purpose: This program uses ACE_FIFO wrappers to perform interprocess
// $Id$
- communication between a parent process and a child process.
- The parents reads from an input file and writes it into the fifo.
- The child reads from the ACE_FIFO and executes the more command. */
+// Purpose: This program uses ACE_FIFO wrappers to perform
+// interprocess communication between a parent process and a child
+// process. The parents reads from an input file and writes it into
+// the fifo. The child reads from the ACE_FIFO and executes the more
+// command.
#include "ace/Log_Msg.h"
#include "ace/FIFO_Recv.h"
@@ -18,7 +19,7 @@ const char *FIFO_NAME = "/tmp/fifo";
int
do_child (ACE_FIFO_Recv &fifo_reader)
{
- /* Set child's stdin to read from the fifo */
+ // Set child's stdin to read from the fifo.
if (ACE_OS::close (0) == -1 || ACE_OS::dup (fifo_reader.get_handle ()) == -1)
return -1;
@@ -28,6 +29,7 @@ do_child (ACE_FIFO_Recv &fifo_reader)
if (ACE_OS::execvp (EXEC_NAME, argv) == -1)
return -1;
+ return 0;
}
int
@@ -44,7 +46,7 @@ do_parent (const char fifo_name[], char input_filename[])
if ((inputfd = ACE_OS::open (input_filename, O_RDONLY)) == -1)
return -1;
- /* Read from input file and write into input end of the fifo */
+ // Read from input file and write into input end of the fifo.
while ((len = ACE_OS::read (inputfd, buf, sizeof buf)) > 0)
if (fifo_sender.send (buf, len) != len)
@@ -84,7 +86,8 @@ main (int argc, char *argv[])
if (do_parent (FIFO_NAME, argv[1]) == -1)
ACE_ERROR ((LM_ERROR, "%n: %p\n%a", "do_parent", 1));
- if (ACE_OS::waitpid (child_pid, (int *) 0, 0) == -1) /* wait for child to ACE_OS::exit */
+ // wait for child to ACE_OS::exit.
+ if (ACE_OS::waitpid (child_pid, (int *) 0, 0) == -1)
ACE_ERROR ((LM_ERROR, "%n: %p\n%a", "waitpid", 1));
}
diff --git a/examples/IPC_SAP/SOCK_SAP/FD-unclient.cpp b/examples/IPC_SAP/SOCK_SAP/FD-unclient.cpp
index 4c7f2d96052..2165064ab83 100644
--- a/examples/IPC_SAP/SOCK_SAP/FD-unclient.cpp
+++ b/examples/IPC_SAP/SOCK_SAP/FD-unclient.cpp
@@ -1,6 +1,6 @@
-#include "ace/LSOCK_Connector.h"
// $Id$
+#include "ace/LSOCK_Connector.h"
#include "ace/UNIX_Addr.h"
#if defined (ACE_HAS_MSG) && !defined (ACE_HAS_UNIX_DOMAIN_SOCKETS)
@@ -10,26 +10,25 @@ int
main (int argc, char *argv[])
{
char *file_name = argc > 1 ? argv[1] : "./local_data";
- char *send_str = argc > 2 ? argv[2] : "hello world";
- char *rendezvous = argc > 3 ? argv[3] : ACE_DEFAULT_RENDEZVOUS;
- int fd;
+ char *rendezvous = argc > 2 ? argv[2] : ACE_DEFAULT_RENDEZVOUS;
+ ACE_HANDLE handle;
int n;
char buf[BUFSIZ];
ACE_LSOCK_Stream cli_stream;
ACE_UNIX_Addr addr (rendezvous);
- /* Establish the connection with server */
+ // Establish the connection with server.
ACE_LSOCK_Connector connector;
if (connector.connect (cli_stream, addr) == -1)
ACE_OS::perror ("connect"), ACE_OS::exit (1);
- if ((fd = ACE_OS::open (file_name, O_RDONLY)) == -1)
+ if ((handle = ACE_OS::open (file_name, O_RDONLY)) == -1)
ACE_OS::perror ("open"), ACE_OS::exit (1);
- /* Send data to server (correctly handles incomplete writes) */
- if (cli_stream.send_handle (fd) == -1)
+ // Send handle to server (correctly handles incomplete writes).
+ if (cli_stream.send_handle (handle) == -1)
ACE_OS::perror ("send"), ACE_OS::exit (1);
if ((n = cli_stream.recv_n (buf, sizeof buf)) == -1)
@@ -37,7 +36,7 @@ main (int argc, char *argv[])
else
ACE_OS::write (ACE_STDOUT, buf, n);
- /* Explicitly close the connection */
+ // Explicitly close the connection.
if (cli_stream.close () == -1)
ACE_OS::perror ("close"), ACE_OS::exit (1);
diff --git a/examples/IPC_SAP/SOCK_SAP/FD-unserver.cpp b/examples/IPC_SAP/SOCK_SAP/FD-unserver.cpp
index 219ba019c33..38cf2b9de8c 100644
--- a/examples/IPC_SAP/SOCK_SAP/FD-unserver.cpp
+++ b/examples/IPC_SAP/SOCK_SAP/FD-unserver.cpp
@@ -1,50 +1,51 @@
-#include "ace/LSOCK_Acceptor.h"
// $Id$
+#include "ace/LSOCK_Acceptor.h"
#include "ace/LSOCK_Stream.h"
#include "ace/UNIX_Addr.h"
#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS)
-/* ACE_SOCK Server */
+// ACE_LSOCK Server
int
main (int argc, char *argv[])
{
char *rendezvous = argc > 1 ? argv[1] : ACE_DEFAULT_RENDEZVOUS;
- /* Create a server */
+ // Create a server.
ACE_OS::unlink (rendezvous);
ACE_UNIX_Addr addr (rendezvous);
ACE_LSOCK_Acceptor peer_acceptor (addr);
ACE_LSOCK_Stream new_stream;
- /* Performs the iterative server activities */
+ // Performs the iterative server activities.
for (;;)
{
char buf[BUFSIZ];
- int fd;
+ ACE_HANDLE handle;
- /* Create a new ACE_SOCK_Stream endpoint */
+ // Create a new ACE_SOCK_Stream endpoint.
if (peer_acceptor.accept (new_stream) == -1)
ACE_OS::perror ("accept");
- /* Read data from client (correctly handles incomplete reads due to flow control) */
+ // Read data from client (correctly handles incomplete reads due
+ // to flow control).
- if (new_stream.recv_handle (fd) == -1)
- ::perror ("recv_handle"), ACE_OS::exit (1);
+ if (new_stream.recv_handle (handle) == -1)
+ ACE_OS::perror ("recv_handle"), ACE_OS::exit (1);
ACE_OS::puts ("----------------------------------------");
- for (int n; (n = ACE_OS::read (fd, buf, sizeof buf)) > 0; )
- ::write (1, buf, n);
+ for (int n; (n = ACE_OS::read (handle, buf, sizeof buf)) > 0; )
+ ACE_OS::write (ACE_STDOUT, buf, n);
ACE_OS::puts ("----------------------------------------");
if (new_stream.send ("yow", 3) == -1)
- ::perror ("send"), ACE_OS::exit (1);
+ ACE_OS::perror ("send"), ACE_OS::exit (1);
- /* Close new endpoint (listening endpoint stays open) */
+ // Close new endpoint (listening endpoint stays open).
if (new_stream.close () == -1)
ACE_OS::perror ("close");
}