diff options
author | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-02-19 05:41:57 +0000 |
---|---|---|
committer | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-02-19 05:41:57 +0000 |
commit | 2e96fa1b424f99016c153cd28815723bef4ed9a0 (patch) | |
tree | 29638a0251d912c11447966490f39057b2586140 /examples/Reactor | |
parent | d6ff00e0046f7ab4eee33f7631bf1222e5467aaf (diff) | |
download | ATCD-2e96fa1b424f99016c153cd28815723bef4ed9a0.tar.gz |
Modified to run on NT.
Diffstat (limited to 'examples/Reactor')
-rw-r--r-- | examples/Reactor/Dgram/CODgram.cpp | 46 | ||||
-rw-r--r-- | examples/Reactor/Dgram/Dgram.cpp | 46 |
2 files changed, 64 insertions, 28 deletions
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; } |