From ae2c9760c07ac89bc12ee63b36199c05fc4d0c06 Mon Sep 17 00:00:00 2001 From: nanbor Date: Thu, 19 Feb 1998 05:41:57 +0000 Subject: Modified to run on NT. --- examples/Reactor/Dgram/CODgram.cpp | 46 ++++++++++++++++++++++++++------------ examples/Reactor/Dgram/Dgram.cpp | 46 ++++++++++++++++++++++++++------------ 2 files changed, 64 insertions(+), 28 deletions(-) (limited to 'examples') diff --git a/examples/Reactor/Dgram/CODgram.cpp b/examples/Reactor/Dgram/CODgram.cpp index 21dd157e49f..254b6237325 100644 --- a/examples/Reactor/Dgram/CODgram.cpp +++ b/examples/Reactor/Dgram/CODgram.cpp @@ -7,6 +7,7 @@ #include "ace/Reactor.h" #include "ace/SOCK_CODgram.h" #include "ace/INET_Addr.h" +#include "ace/Process.h" // Port used to receive for dgrams. static u_short port1; @@ -162,23 +163,40 @@ main (int argc, char *argv[]) const char *remotehost = argc > 2 ? argv[2] : ACE_DEFAULT_SERVER_HOST; const u_short port2 = argc > 3 ? ACE_OS::atoi (argv[3]) : port1 + 1; - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) local port = %d, remote host = %s, remote port = %d\n", - port1, remotehost, port2)); - - switch (ACE_OS::fork (argv[0])) + if (argc > 4) // Providing the fourth command line argument + { // indicate we don't want to spawn a new process. + // On Win32, we use this to exec the new program. + run_test (port1, remotehost, port2); + } + else { - case -1: - return -1; + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) local port = %d, remote host = %s, remote port = %d\n", + port1, remotehost, port2)); + + ACE_Process_Options options; + options.command_line ("%s %d %s %d %c", argv[0], port1, remotehost, port2, 'c'); + options.creation_flags (ACE_Process_Options::NO_EXEC); // This has no effect on + // NT and will spawn a + // process that exec + // the above run_test + // function. + + ACE_Process new_process; + switch (new_process.spawn (options)) + { + case -1: + return -1; - case 0: - run_test (port1, remotehost, port2); - break; + case 0: + run_test (port1, remotehost, port2); + break; - default: - run_test (port2, remotehost, port1); - break; + default: + run_test (port2, remotehost, port1); + new_process.wait (); + break; + } } - return 0; } diff --git a/examples/Reactor/Dgram/Dgram.cpp b/examples/Reactor/Dgram/Dgram.cpp index 33e306c4af4..ca62c64bfbd 100644 --- a/examples/Reactor/Dgram/Dgram.cpp +++ b/examples/Reactor/Dgram/Dgram.cpp @@ -5,6 +5,7 @@ // parent and child process. #include "ace/Reactor.h" +#include "ace/Process.h" #include "ace/SOCK_Dgram.h" #include "ace/INET_Addr.h" @@ -160,23 +161,40 @@ main (int argc, char *argv[]) const char *remotehost = argc > 2 ? argv[2] : ACE_DEFAULT_SERVER_HOST; const u_short port2 = argc > 3 ? ACE_OS::atoi (argv[3]) : port1 + 1; - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) local port = %d, remote host = %s, remote port = %d\n", - port1, remotehost, port2)); - - switch (ACE_OS::fork (argv[0])) + if (argc > 4) // Providing the fourth command line argument + { // indicate we don't want to spawn a new process. + // On Win32, we use this to exec the new program. + run_test (port1, remotehost, port2); + } + else { - case -1: - return -1; + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) local port = %d, remote host = %s, remote port = %d\n", + port1, remotehost, port2)); + + ACE_Process_Options options; + options.command_line ("%s %d %s %d %c", argv[0], port1, remotehost, port2, 'c'); + options.creation_flags (ACE_Process_Options::NO_EXEC); // This has no effect on + // NT and will spawn a + // process that exec + // the above run_test + // function. + + ACE_Process new_process; + switch (new_process.spawn (options)) + { + case -1: + return -1; - case 0: - run_test (port1, remotehost, port2); - break; + case 0: + run_test (port1, remotehost, port2); + break; - default: - run_test (port2, remotehost, port1); - break; + default: + run_test (port2, remotehost, port1); + new_process.wait (); + break; + } } - return 0; } -- cgit v1.2.1