diff options
author | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1996-10-21 21:41:34 +0000 |
---|---|---|
committer | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1996-10-21 21:41:34 +0000 |
commit | a5fdebc5f6375078ec1763850a4ca23ec7fe6458 (patch) | |
tree | bcf0a25c3d45a209a6e3ac37b233a4812f29c732 /examples | |
download | ATCD-a5fdebc5f6375078ec1763850a4ca23ec7fe6458.tar.gz |
Initial revision
Diffstat (limited to 'examples')
298 files changed, 31678 insertions, 0 deletions
diff --git a/examples/ASX/CCM_App/CCM_App.cpp b/examples/ASX/CCM_App/CCM_App.cpp new file mode 100644 index 00000000000..218b3037be2 --- /dev/null +++ b/examples/ASX/CCM_App/CCM_App.cpp @@ -0,0 +1,123 @@ +#define ACE_BUILD_SVC_DLL +// @(#)CCM_App.cpp 1.1 10/18/96 + +#include "ace/Stream.h" +#include "ace/Task.h" +#include "ace/Module.h" + +typedef ACE_Task<ACE_SYNCH> MT_Task; +typedef ACE_Stream<ACE_SYNCH> MT_Stream; +typedef ACE_Module<ACE_SYNCH> MT_Module; + +class ACE_Svc_Export Test_Task : public MT_Task +{ +public: + virtual int open (void *); + virtual int close (u_long); + virtual int put (ACE_Message_Block *, ACE_Time_Value * = 0); + virtual int svc (void); + virtual int info (char **, size_t) const; + virtual int init (int, char *[]); + virtual int fini (void); + virtual int suspend (void); + virtual int resume (void); +}; + +int +Test_Task::open (void *) +{ + ACE_DEBUG ((LM_DEBUG, "opening %s\n", this->name () ? this->name () : "task")); + return 0; +} + +int +Test_Task::close (u_long) +{ + ACE_DEBUG ((LM_DEBUG, "closing %s\n", this->name () ? this->name () : "task")); + return 0; +} + +int +Test_Task::suspend (void) +{ + ACE_DEBUG ((LM_DEBUG, "suspending in %s\n", this->name () ? this->name () : "task")); + return 0; +} + +int +Test_Task::resume (void) +{ + ACE_DEBUG ((LM_DEBUG, "resuming in %s\n", this->name () ? this->name () : "task")); + return 0; +} + +int +Test_Task::put (ACE_Message_Block *, ACE_Time_Value *) +{ + return 0; +} + +int +Test_Task::svc (void) +{ + return 0; +} + +int +Test_Task::info (char **, size_t) const +{ + return 0; +} + +int +Test_Task::init (int, char *[]) +{ + ACE_DEBUG ((LM_DEBUG, "initializing %s\n", this->name () ? this->name () : "task")); + + return 0; +} + +int +Test_Task::fini (void) +{ + ACE_DEBUG ((LM_DEBUG, "finalizing %s\n", this->name () ? this->name () : "task")); + return 0; +} + +// Dynamically linked functions used to control configuration. + +extern "C" ACE_Svc_Export MT_Stream *make_stream (void); +extern "C" ACE_Svc_Export MT_Module *make_da (void); +extern "C" ACE_Svc_Export MT_Module *make_ea (void); +extern "C" ACE_Svc_Export MT_Module *make_mr (void); +extern "C" ACE_Svc_Export ACE_Service_Object *make_task (void); + +ACE_Service_Object * +make_task (void) +{ + return new Test_Task; +} + +MT_Stream * +make_stream (void) +{ + return new MT_Stream; +} + +MT_Module * +make_da (void) +{ + return new MT_Module ("Device_Adapter", new Test_Task, new Test_Task); +} + +MT_Module * +make_ea (void) +{ + return new MT_Module ("Event_Analyzer", new Test_Task, new Test_Task); +} + +MT_Module * +make_mr (void) +{ + return new MT_Module ("Multicast_Router", new Test_Task, new Test_Task); +} diff --git a/examples/ASX/CCM_App/Makefile b/examples/ASX/CCM_App/Makefile new file mode 100644 index 00000000000..3902aef1235 --- /dev/null +++ b/examples/ASX/CCM_App/Makefile @@ -0,0 +1,176 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for CCM tests +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = SC_Client \ + SC_Server + +LSRC = $(addsuffix .cpp,$(BIN)) \ + CCM_App.cpp + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VSHLIB) $(SHLIBA) $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.lib.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/SC_Client.o .shobj/SC_Client.so: SC_Client.cpp +.obj/SC_Server.o .shobj/SC_Server.so: SC_Server.cpp \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h +.obj/CCM_App.o .shobj/CCM_App.so: CCM_App.cpp \ + $(WRAPPER_ROOT)/ace/Stream.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Stream.cpp \ + $(WRAPPER_ROOT)/ace/Stream.i + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/ASX/CCM_App/SC_Client.cpp b/examples/ASX/CCM_App/SC_Client.cpp new file mode 100644 index 00000000000..498ff89ba9b --- /dev/null +++ b/examples/ASX/CCM_App/SC_Client.cpp @@ -0,0 +1,9 @@ +// Pretty simple, eh? ;-) +// @(#)SC_Client.cpp 1.1 10/18/96 + + +int +main (int, char *[]) +{ + return 0; +} diff --git a/examples/ASX/CCM_App/SC_Server.cpp b/examples/ASX/CCM_App/SC_Server.cpp new file mode 100644 index 00000000000..49a11179dcd --- /dev/null +++ b/examples/ASX/CCM_App/SC_Server.cpp @@ -0,0 +1,63 @@ +// Simple driver program for the server. +// @(#)SC_Server.cpp 1.1 10/18/96 + + +#include "ace/Service_Config.h" +#include "ace/Synch.h" +#include "ace/Signal.h" + +class Event_Handler : public ACE_Event_Handler +{ +public: + virtual int handle_input (ACE_HANDLE handle); + virtual int handle_close (ACE_HANDLE, + ACE_Reactor_Mask); +}; + +int +Event_Handler::handle_input (ACE_HANDLE handle) +{ + char buf[BUFSIZ]; + + ssize_t n = ACE_OS::read (handle, buf, sizeof buf); + + if (n == -1) + return -1; + else if (ACE_OS::write (ACE_STDOUT, buf, n) != n) + return -1; + else + return 0; +} + +int +Event_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) +{ + ACE_DEBUG ((LM_DEBUG, "closing Event_Handler\n")); + return 0; +} + +int +main (int argc, char *argv[]) +{ + ACE_Service_Config loggerd; + Event_Handler handler; + ACE_Sig_Adapter shutdown_handler ((ACE_Sig_Handler_Ex) ACE_Service_Config::end_reactor_event_loop); + + if (ACE::register_stdin_handler (&handler, + ACE_Service_Config::reactor (), + ACE_Service_Config::thr_mgr ()) == -1) + ACE_ERROR ((LM_ERROR, "%p\n", "register_stdin_handler")); + + if (loggerd.open (argc, argv) == -1 && errno != ENOENT) + ACE_ERROR ((LM_ERROR, "%p\n%a", "open", 1)); + + else if (ACE_Service_Config::reactor ()->register_handler + (SIGINT, &shutdown_handler) == -1) + ACE_ERROR ((LM_ERROR, "%p\n%a", "register_handler", 1)); + + // Perform logging service until we receive SIGINT. + + loggerd.run_reactor_event_loop (); + + return 0; +} diff --git a/examples/ASX/CCM_App/svc.conf b/examples/ASX/CCM_App/svc.conf new file mode 100644 index 00000000000..4737cc6312e --- /dev/null +++ b/examples/ASX/CCM_App/svc.conf @@ -0,0 +1,21 @@ +static ACE_Service_Manager "-d -p 3911" + +dynamic My_Task Service_Object *.shobj/CCM_App.so:make_task() "-p 3000" + +stream dynamic CCM_App STREAM *.shobj/CCM_App.so:make_stream() active +{ + dynamic Device_Adapter Module *.shobj/CCM_App.so:make_da() + dynamic Event_Analyzer Module *.shobj/CCM_App.so:make_ea() + dynamic Multicast_Router Module *.shobj/CCM_App.so:make_mr() "-p 3001" +} + +stream CCM_App +{ + remove Device_Adapter + remove Event_Analyzer + remove Multicast_Router +} + +remove CCM_App +remove My_Task + diff --git a/examples/ASX/Event_Server/Event_Server/Consumer_Router.cpp b/examples/ASX/Event_Server/Event_Server/Consumer_Router.cpp new file mode 100644 index 00000000000..aad0adf313e --- /dev/null +++ b/examples/ASX/Event_Server/Event_Server/Consumer_Router.cpp @@ -0,0 +1,132 @@ +#include "ace/Log_Msg.h" +// @(#)Consumer_Router.cpp 1.1 10/18/96 + +#include "Consumer_Router.h" +#include "Options.h" + +#if defined (ACE_HAS_THREADS) + +typedef Acceptor_Factory<Consumer_Handler, CONSUMER_KEY> CONSUMER_FACTORY; + +int +Consumer_Handler::open (void *a) +{ + CONSUMER_FACTORY *af = (CONSUMER_FACTORY *) a; + this->router_task_ = af->router (); + return this->Peer_Handler<CONSUMER_ROUTER, CONSUMER_KEY>::open (a); +} + +Consumer_Handler::Consumer_Handler (ACE_Thread_Manager *tm) + : Peer_Handler<CONSUMER_ROUTER, CONSUMER_KEY> (tm) +{ +} + +// Create a new handler that will interact with a consumer and point +// its ROUTER_TASK_ data member to the CONSUMER_ROUTER. + +Consumer_Router::Consumer_Router (ACE_Thread_Manager *tm) + : CONSUMER_ROUTER (tm) +{ +} + +// Initialize the Router. + +int +Consumer_Router::open (void *) +{ + assert (this->is_reader ()); + + char *argv[4]; + + argv[0] = (char *) this->name (); + argv[1] = "-p"; + argv[2] = options.consumer_port (); + argv[3] = 0; + + if (this->init (2, &argv[1]) == -1) + return -1; + + // Make this an active object. + return this->activate (options.t_flags ()); +} + +int +Consumer_Router::close (u_long) +{ + assert (this->is_reader ()); + ACE_DEBUG ((LM_DEBUG, "(%t) closing Consumer_Router\n")); + this->peer_map_.close (); + + // Inform the thread to shut down. + this->msg_queue ()->deactivate (); + return 0; +} + +// Handle incoming messages in a separate thread. + +int +Consumer_Router::svc (void) +{ + ACE_Thread_Control tc (this->thr_mgr ()); + ACE_Message_Block *mb = 0; + + assert (this->is_reader ()); + + ACE_DEBUG ((LM_DEBUG, "(%t) starting svc in Consumer_Router\n")); + + while (this->getq (mb) >= 0) + { + ACE_DEBUG ((LM_DEBUG, "Consumer_Router is routing via send_peers\n")); + if (this->send_peers (mb) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "(%t) send_peers failed in Consumer_Router\n"), + -1); + } + ACE_DEBUG ((LM_DEBUG, "(%t) stopping svc in Consumer_Router\n")); + return 0; + // Note the implicit ACE_OS::thr_exit() via destructor. +} + +// Send a MESSAGE_BLOCK to the supplier(s). + +int +Consumer_Router::put (ACE_Message_Block *mb, ACE_Time_Value *) +{ + assert (this->is_reader ()); + + if (mb->msg_type () == ACE_Message_Block::MB_IOCTL) + { + this->control (mb); + return this->put_next (mb); + } + else + // Queue up the message, which will be processed by + // Consumer_Router::svc(). + return this->putq (mb); +} + +// Return information about the Client_Router ACE_Module. + +int +Consumer_Router::info (char **strp, size_t length) const +{ + char buf[BUFSIZ]; + ACE_INET_Addr addr; + const char *mod_name = this->name (); + ACE_SOCK_Acceptor &sa = this->acceptor_->acceptor (); + + if (sa.get_local_addr (addr) == -1) + return -1; + + ACE_OS::sprintf (buf, "%s\t %d/%s %s", + mod_name, addr.get_port_number (), "tcp", + "# consumer router\n"); + + if (*strp == 0 && (*strp = ACE_OS::strdup (mod_name)) == 0) + return -1; + else + ACE_OS::strncpy (*strp, mod_name, length); + return ACE_OS::strlen (mod_name); +} + +#endif /* ACE_HAS_THREADS */ diff --git a/examples/ASX/Event_Server/Event_Server/Consumer_Router.h b/examples/ASX/Event_Server/Event_Server/Consumer_Router.h new file mode 100644 index 00000000000..efc5acf9e3d --- /dev/null +++ b/examples/ASX/Event_Server/Event_Server/Consumer_Router.h @@ -0,0 +1,46 @@ +/* -*- C++ -*- */ +// @(#)Consumer_Router.h 1.1 10/18/96 + +/* The interface between one or more consumers and an Event Server ACE_Stream */ + +#if !defined (_CONSUMER_ROUTER_H) +#define _CONSUMER_ROUTER_H + +#include "ace/Thread_Manager.h" +#include "ace/SOCK_Acceptor.h" +#include "ace/UPIPE_Acceptor.h" +#include "ace/Svc_Handler.h" +#include "Peer_Router.h" + +#if defined (ACE_HAS_THREADS) + +class Consumer_Handler; /* Forward declaration... */ + +typedef ACE_HANDLE CONSUMER_KEY; + +typedef Peer_Router<Consumer_Handler, CONSUMER_KEY> CONSUMER_ROUTER; + +class Consumer_Handler : public Peer_Handler<CONSUMER_ROUTER, CONSUMER_KEY> +{ +public: + Consumer_Handler (ACE_Thread_Manager *tm = 0); + virtual int open (void *); +}; + +class Consumer_Router : public CONSUMER_ROUTER +{ +public: + Consumer_Router (ACE_Thread_Manager *thr_manager); + +protected: + /* ACE_Task hooks. */ + virtual int open (void *a = 0); + virtual int close (u_long flags = 0); + virtual int put (ACE_Message_Block *msg, ACE_Time_Value * = 0); + virtual int svc (void); + + /* Dynamic linking hooks */ + virtual int info (char **info_string, size_t length) const; +}; +#endif /* ACE_HAS_THREADS */ +#endif /* _CONSUMER_ROUTER_H */ diff --git a/examples/ASX/Event_Server/Event_Server/Event_Analyzer.cpp b/examples/ASX/Event_Server/Event_Server/Event_Analyzer.cpp new file mode 100644 index 00000000000..977e5c4af9d --- /dev/null +++ b/examples/ASX/Event_Server/Event_Server/Event_Analyzer.cpp @@ -0,0 +1,68 @@ +#include "Event_Analyzer.h" +// @(#)Event_Analyzer.cpp 1.1 10/18/96 + + +#if defined (ACE_HAS_THREADS) + +int +Event_Analyzer::open (void *) +{ + return 0; +} + +int +Event_Analyzer::close (u_long) +{ + return 0; +} + +int +Event_Analyzer::control (ACE_Message_Block *mb) +{ + ACE_IO_Cntl_Msg *ioc = (ACE_IO_Cntl_Msg *) mb->rd_ptr (); + ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd; + + switch (cmd = ioc->cmd ()) + { + case ACE_IO_Cntl_Msg::SET_LWM: + case ACE_IO_Cntl_Msg::SET_HWM: + this->water_marks (cmd, *(size_t *) mb->cont ()->rd_ptr ()); + break; + } + return 0; +} + +int +Event_Analyzer::put (ACE_Message_Block *mb, ACE_Time_Value *) +{ + if (mb->msg_type () == ACE_Message_Block::MB_IOCTL) + this->control (mb); + + return this->put_next (mb); +} + +int +Event_Analyzer::init (int, char *[]) +{ + return 0; +} + +int +Event_Analyzer::fini (void) +{ + return 0; +} + +int +Event_Analyzer::info (char **strp, size_t length) const +{ + const char *mod_name = this->name (); + + if (*strp == 0 && (*strp = ACE_OS::strdup (mod_name)) == 0) + return -1; + else + ACE_OS::strncpy (*strp, mod_name, length); + return ACE_OS::strlen (mod_name); +} + +#endif /* ACE_HAS_THREADS */ diff --git a/examples/ASX/Event_Server/Event_Server/Event_Analyzer.h b/examples/ASX/Event_Server/Event_Server/Event_Analyzer.h new file mode 100644 index 00000000000..9d38611e7aa --- /dev/null +++ b/examples/ASX/Event_Server/Event_Server/Event_Analyzer.h @@ -0,0 +1,34 @@ +/* -*- C++ -*- */ +// @(#)Event_Analyzer.h 1.1 10/18/96 + +/* Signal router */ + +#if !defined (_EVENT_ANALYZER_H) +#define _EVENT_ANALYZER_H + +#include "ace/Stream.h" +#include "ace/Module.h" +#include "ace/Task.h" +#include "ace/Synch.h" + +#if defined (ACE_HAS_THREADS) + +class Event_Analyzer : public ACE_Task<ACE_MT_SYNCH> +{ +public: + virtual int open (void *a = 0); + virtual int close (u_long flags = 0); + virtual int put (ACE_Message_Block *msg, ACE_Time_Value * = 0); + virtual int svc (void) { return 0; } + + /* Dynamic linking hooks */ + virtual int init (int argc, char *argv[]); + virtual int fini (void); + virtual int info (char **info_string, size_t length) const; + +private: + virtual int control (ACE_Message_Block *); +}; + +#endif /* ACE_HAS_THREADS */ +#endif /* _EVENT_ANALYZER_H */ diff --git a/examples/ASX/Event_Server/Event_Server/Makefile b/examples/ASX/Event_Server/Event_Server/Makefile new file mode 100644 index 00000000000..947f50c5d7a --- /dev/null +++ b/examples/ASX/Event_Server/Event_Server/Makefile @@ -0,0 +1,433 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the Event Server test +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = event_server + +FILES = Options \ + Supplier_Router \ + Event_Analyzer \ + Consumer_Router \ + Peer_Router + +LSRC = $(addsuffix .cpp,$(FILES)) +LOBJ = $(addsuffix .o,$(FILES)) +SHOBJ = $(addsuffix .so,$(FILES)) + +LDLIBS = $(addprefix .shobj/,$(SHOBJ)) + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.lib.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/Options.o .shobj/Options.so: Options.cpp \ + $(WRAPPER_ROOT)/ace/Get_Opt.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + Options.h \ + $(WRAPPER_ROOT)/ace/Profile_Timer.h \ + Options.i +.obj/Supplier_Router.o .shobj/Supplier_Router.so: Supplier_Router.cpp Supplier_Router.h \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Acceptor.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Map_Manager.h \ + $(WRAPPER_ROOT)/ace/Map_Manager.cpp \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Map_Manager.i \ + $(WRAPPER_ROOT)/ace/Svc_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch_Options.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Svc_Handler.cpp \ + $(WRAPPER_ROOT)/ace/Dynamic.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.i \ + Peer_Router.h \ + $(WRAPPER_ROOT)/ace/Acceptor.h \ + $(WRAPPER_ROOT)/ace/Strategies.h \ + $(WRAPPER_ROOT)/ace/Strategies.cpp \ + $(WRAPPER_ROOT)/ace/Acceptor.i \ + $(WRAPPER_ROOT)/ace/Acceptor.cpp \ + Peer_Router.cpp \ + $(WRAPPER_ROOT)/ace/Get_Opt.h \ + Options.h \ + $(WRAPPER_ROOT)/ace/Profile_Timer.h \ + Options.i +.obj/Event_Analyzer.o .shobj/Event_Analyzer.so: Event_Analyzer.cpp Event_Analyzer.h \ + $(WRAPPER_ROOT)/ace/Stream.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Stream.cpp \ + $(WRAPPER_ROOT)/ace/Stream.i +.obj/Consumer_Router.o .shobj/Consumer_Router.so: Consumer_Router.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + Consumer_Router.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/SOCK_Acceptor.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/UPIPE_Acceptor.h \ + $(WRAPPER_ROOT)/ace/UPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/Stream.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Stream.cpp \ + $(WRAPPER_ROOT)/ace/Stream.i \ + $(WRAPPER_ROOT)/ace/SPIPE.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/SPIPE.i \ + $(WRAPPER_ROOT)/ace/UPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Acceptor.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.i \ + $(WRAPPER_ROOT)/ace/UPIPE_Acceptor.i \ + $(WRAPPER_ROOT)/ace/Svc_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch_Options.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.cpp \ + $(WRAPPER_ROOT)/ace/Dynamic.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.i \ + Peer_Router.h \ + $(WRAPPER_ROOT)/ace/Acceptor.h \ + $(WRAPPER_ROOT)/ace/Strategies.h \ + $(WRAPPER_ROOT)/ace/Strategies.cpp \ + $(WRAPPER_ROOT)/ace/Acceptor.i \ + $(WRAPPER_ROOT)/ace/Acceptor.cpp \ + $(WRAPPER_ROOT)/ace/Map_Manager.h \ + $(WRAPPER_ROOT)/ace/Map_Manager.cpp \ + $(WRAPPER_ROOT)/ace/Map_Manager.i \ + Peer_Router.cpp \ + $(WRAPPER_ROOT)/ace/Get_Opt.h \ + Options.h \ + $(WRAPPER_ROOT)/ace/Profile_Timer.h \ + Options.i +.obj/Peer_Router.o .shobj/Peer_Router.so: Peer_Router.cpp \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Get_Opt.h \ + Options.h \ + $(WRAPPER_ROOT)/ace/Profile_Timer.h \ + Options.i Peer_Router.h \ + $(WRAPPER_ROOT)/ace/Acceptor.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch_Options.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Svc_Handler.cpp \ + $(WRAPPER_ROOT)/ace/Dynamic.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.i \ + $(WRAPPER_ROOT)/ace/Strategies.h \ + $(WRAPPER_ROOT)/ace/Strategies.cpp \ + $(WRAPPER_ROOT)/ace/Acceptor.i \ + $(WRAPPER_ROOT)/ace/Acceptor.cpp \ + $(WRAPPER_ROOT)/ace/SOCK_Acceptor.h \ + $(WRAPPER_ROOT)/ace/Map_Manager.h \ + $(WRAPPER_ROOT)/ace/Map_Manager.cpp \ + $(WRAPPER_ROOT)/ace/Map_Manager.i \ + Peer_Router.cpp + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/ASX/Event_Server/Event_Server/Options.cpp b/examples/ASX/Event_Server/Event_Server/Options.cpp new file mode 100644 index 00000000000..41658639a77 --- /dev/null +++ b/examples/ASX/Event_Server/Event_Server/Options.cpp @@ -0,0 +1,186 @@ +#include "ace/Get_Opt.h" +// @(#)Options.cpp 1.1 10/18/96 + +#include "ace/Synch.h" +#include "ace/Thread.h" +#include "ace/Log_Msg.h" +#include "Options.h" + +#if defined (ACE_HAS_THREADS) + +Options::Options (void) + : debugging_ (0), + verbosity_ (0), + low_water_mark_ (1024), + high_water_mark_ (8 * 1024), + message_size_ (128), + thr_count_ (4), + initial_queue_length_ (0), + iterations_ (100000), + consumer_port_ ("-p " ACE_ITOA (10000)), + supplier_port_ ("-p " ACE_ITOA (10001)), + t_flags_ (THR_DETACHED) +{ +} + +Options::~Options (void) +{ +} + +void Options::print_results (void) +{ +#if !defined (ACE_WIN32) + ACE_Profile_Timer::ACE_Elapsed_Time et; + ACE_Profile_Timer::Rusage rusage; + + this->itimer_.elapsed_time (et); + this->itimer_.get_rusage (rusage); + + if (options.verbose ()) + { +#if defined (ACE_HAS_PRUSAGE_T) + ACE_OS::printf ("final concurrency hint = %d\n", ACE_Thread::getconcurrency ()); + ACE_OS::printf ("%8d = lwpid\n" + "%8d = lwp count\n" + "%8d = minor page faults\n" + "%8d = major page faults\n" + "%8d = input blocks\n" + "%8d = output blocks\n" + "%8d = messages sent\n" + "%8d = messages received\n" + "%8d = signals received\n" + "%8ds, %dms = wait-cpu (latency) time\n" + "%8ds, %dms = user lock wait sleep time\n" + "%8ds, %dms = all other sleep time\n" + "%8d = voluntary context switches\n" + "%8d = involuntary context switches\n" + "%8d = system calls\n" + "%8d = chars read/written\n", + rusage.pr_lwpid, + rusage.pr_count, + rusage.pr_minf, + rusage.pr_majf, + rusage.pr_inblk, + rusage.pr_oublk, + rusage.pr_msnd, + rusage.pr_mrcv, + rusage.pr_sigs, + rusage.pr_wtime.tv_sec, rusage.pr_wtime.tv_nsec / 1000000, + rusage.pr_ltime.tv_sec, rusage.pr_ltime.tv_nsec / 1000000, + rusage.pr_slptime.tv_sec, rusage.pr_slptime.tv_nsec / 1000000, + rusage.pr_vctx, + rusage.pr_ictx, + rusage.pr_sysc, + rusage.pr_ioch); +#else + /* Someone needs to write the corresponding dump for rusage... */ +#endif /* ACE_HAS_PRUSAGE_T */ + } + + ACE_OS::printf ("---------------------\n" + "real time = %.3f\n" + "user time = %.3f\n" + "system time = %.3f\n" + "---------------------\n", + et.real_time, et.user_time, et.system_time); +#endif /* ACE_WIN32 */ +} + +/* Manages the options */ +Options options; + +void +Options::parse_args (int argc, char *argv[]) +{ + ACE_LOG_MSG->open (argv[0]); + + ACE_Get_Opt get_opt (argc, argv, "c:bdH:i:L:l:M:ns:t:T:v"); + int c; + + while ((c = get_opt ()) != -1) + switch (c) + { + case 'b': + this->t_flags (THR_BOUND); + break; + case 'c': + this->consumer_port (get_opt.optarg); + break; + case 'd': + this->debugging_ = 1; + break; + case 'H': + this->high_water_mark (ACE_OS::atoi (get_opt.optarg)); + break; + case 'i': + this->iterations (ACE_OS::atoi (get_opt.optarg)); + break; + case 'L': + this->low_water_mark (ACE_OS::atoi (get_opt.optarg)); + break; + case 'l': + this->initial_queue_length (ACE_OS::atoi (get_opt.optarg)); + break; + case 'M': + this->message_size (ACE_OS::atoi (get_opt.optarg)); + break; + case 'n': + this->t_flags (THR_NEW_LWP); + break; + case 's': + this->supplier_port (get_opt.optarg); + break; + case 'T': + if (ACE_OS::strcasecmp (get_opt.optarg, "ON") == 0) + ACE_Trace::start_tracing (); + else if (ACE_OS::strcasecmp (get_opt.optarg, "OFF") == 0) + ACE_Trace::stop_tracing (); + break; + case 't': + this->thr_count (ACE_OS::atoi (get_opt.optarg)); + break; + case 'v': + this->verbosity_ = 1; + break; + default: + ::fprintf (stderr, "%s\n" + "\t[-b] (THR_BOUND)\n" + "\t[-c consumer port]\n" + "\t[-d] (enable debugging)\n" + "\t[-H high water mark]\n" + "\t[-i number of test iterations]\n" + "\t[-L low water mark]\n" + "\t[-M] message size \n" + "\t[-n] (THR_NEW_LWP)\n" + "\t[-q max queue size]\n" + "\t[-s supplier port]\n" + "\t[-t number of threads]\n" + "\t[-v] (verbose) \n", + argv[0]); + ::exit (1); + /* NOTREACHED */ + break; + } + + if (this->verbose ()) + ACE_OS::printf ("%8d = initial concurrency hint\n" + "%8d = total iterations\n" + "%8d = thread count\n" + "%8d = low water mark\n" + "%8d = high water mark\n" + "%8d = message_size\n" + "%8d = initial queue length\n" + "%8d = THR_BOUND\n" + "%8d = THR_NEW_LWP\n", + ACE_Thread::getconcurrency (), + this->iterations (), + this->thr_count (), + this->low_water_mark (), + this->high_water_mark (), + this->message_size (), + this->initial_queue_length (), + (this->t_flags () & THR_BOUND) != 0, + (this->t_flags () & THR_NEW_LWP) != 0); +} + +#endif /* ACE_HAS_THREADS */ diff --git a/examples/ASX/Event_Server/Event_Server/Options.h b/examples/ASX/Event_Server/Event_Server/Options.h new file mode 100644 index 00000000000..054f0d834f6 --- /dev/null +++ b/examples/ASX/Event_Server/Event_Server/Options.h @@ -0,0 +1,75 @@ +/* -*- C++ -*- */ +// @(#)Options.h 1.1 10/18/96 + +/* Option manager for Event Server */ + +#if !defined (DEVICE_OPTIONS_H) +#define DEVICE_OPTIONS_H + +#include "ace/OS.h" +#include "ace/Profile_Timer.h" + +#if defined (ACE_HAS_THREADS) + +class Options +{ +public: + Options (void); + ~Options (void); + void parse_args (int argc, char *argv[]); + + void stop_timer (void); + void start_timer (void); + + void thr_count (size_t count); + size_t thr_count (void); + + void initial_queue_length (size_t length); + size_t initial_queue_length (void); + + void high_water_mark (size_t size); + size_t high_water_mark (void); + + void low_water_mark (size_t size); + size_t low_water_mark (void); + + void message_size (size_t size); + size_t message_size (void); + + void iterations (size_t n); + size_t iterations (void); + + void t_flags (long flag); + long t_flags (void); + + void supplier_port (char *port); + char *supplier_port (void); + + void consumer_port (char *port); + char *consumer_port (void); + + int debug (void); + int verbose (void); + + void print_results (void); + +private: + ACE_Profile_Timer itimer_; /* Time the process */ + size_t thr_count_; /* Number of threads to spawn */ + long t_flags_; /* Flags to thr_create() */ + size_t high_water_mark_; /* ACE_Task high water mark */ + size_t low_water_mark_; /* ACE_Task low water mark */ + size_t message_size_; /* Size of a message */ + size_t initial_queue_length_; /* Initial number of items in the queue */ + size_t iterations_; /* Number of iterations to run the test program */ + int debugging_; /* Extra debugging info */ + int verbosity_; /* Extra verbose messages */ + char *consumer_port_; /* Port that the Consumer_Router is using */ + char *supplier_port_; /* Port that the Supplier_Router is using */ +}; + +extern Options options; + +#include "Options.i" +#endif /* ACE_HAS_THREADS */ +#endif /* DEVICE_OPTIONS_H */ diff --git a/examples/ASX/Event_Server/Event_Server/Options.i b/examples/ASX/Event_Server/Event_Server/Options.i new file mode 100644 index 00000000000..c538b94b46a --- /dev/null +++ b/examples/ASX/Event_Server/Event_Server/Options.i @@ -0,0 +1,137 @@ +/* -*- C++ -*- */ +// @(#)Options.i 1.1 10/18/96 + +/* Option manager for ustreams */ + +inline void +Options::supplier_port (char *port) +{ + this->supplier_port_ = port; +} + +inline char * +Options::supplier_port (void) +{ + return this->supplier_port_; +} + +inline void +Options::consumer_port (char *port) +{ + this->consumer_port_ = port; +} + +inline char * +Options::consumer_port (void) +{ + return this->consumer_port_; +} + +inline void +Options::start_timer (void) +{ + this->itimer_.start (); +} + +inline void +Options::stop_timer (void) +{ + this->itimer_.stop (); +} + +inline void +Options::thr_count (size_t count) +{ + this->thr_count_ = count; +} + +inline size_t +Options::thr_count (void) +{ + return this->thr_count_; +} + +inline void +Options::initial_queue_length (size_t length) +{ + this->initial_queue_length_ = length; +} + +inline size_t +Options::initial_queue_length (void) +{ + return this->initial_queue_length_; +} + +inline void +Options::high_water_mark (size_t size) +{ + this->high_water_mark_ = size; +} + +inline size_t +Options::high_water_mark (void) +{ + return this->high_water_mark_; +} + +inline void +Options::low_water_mark (size_t size) +{ + this->low_water_mark_ = size; +} + +inline size_t +Options::low_water_mark (void) +{ + return this->low_water_mark_; +} + +inline void +Options::message_size (size_t size) +{ + this->message_size_ = size; +} + +inline size_t +Options::message_size (void) +{ + return this->message_size_; +} + +inline void +Options::iterations (size_t n) +{ + this->iterations_ = n; +} + +inline size_t +Options::iterations (void) +{ + return this->iterations_; +} + +inline void +Options::t_flags (long flag) +{ + this->t_flags_ |= flag; +} + +inline long +Options::t_flags (void) +{ + return this->t_flags_; +} + +inline int +Options::debug (void) +{ + return this->debugging_; +} + +inline int +Options::verbose (void) +{ + return this->verbosity_; +} + diff --git a/examples/ASX/Event_Server/Event_Server/Peer_Router.cpp b/examples/ASX/Event_Server/Event_Server/Peer_Router.cpp new file mode 100644 index 00000000000..f0a77ed7103 --- /dev/null +++ b/examples/ASX/Event_Server/Event_Server/Peer_Router.cpp @@ -0,0 +1,279 @@ +#if !defined (_PEER_ROUTER_C) +// @(#)Peer_Router.cpp 1.1 10/18/96 + +#define _PEER_ROUTER_C + +#include "ace/Service_Config.h" +#include "ace/Get_Opt.h" +#include "ace/Log_Msg.h" +#include "Options.h" +#include "Peer_Router.h" + +#if defined (ACE_HAS_THREADS) + +// Define some short-hand macros to deal with verbose templates +// names... + +#define PH PEER_HANDLER +#define PA PEER_ACCEPTOR +#define PAD PEER_ADDR +#define PK PEER_KEY +#define PM PEER_MAP + +template <class PH, class PK> int +Acceptor_Factory<PH, PK>::init (int argc, char *argv[]) +{ + ACE_Get_Opt get_opt (argc, argv, "dp:", 0); + ACE_INET_Addr addr; + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'p': + addr.set (ACE_OS::atoi (get_opt.optarg)); + break; + case 'd': + break; + default: + break; + } + + if (this->open (addr, ACE_Service_Config::reactor ()) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); + return 0; +} + +template <class PH, class PK> +Acceptor_Factory<PH, PK>::Acceptor_Factory (Peer_Router<PH, PK> *pr) + : pr_ (pr) +{ +} + +template <class PH, class PK> Peer_Router<PH, PK> * +Acceptor_Factory<PH, PK>::router (void) +{ + return this->pr_; +} + +template <class ROUTER, class KEY> +Peer_Handler<ROUTER, KEY>::Peer_Handler (ACE_Thread_Manager *tm) + : inherited (tm) +{ +} + +template <class ROUTER, class KEY> int +Peer_Handler<ROUTER, KEY>::svc (void) +{ +#if 0 + ACE_Thread_Control thread_control (tm); + // Just a try !! we're just reading from our Message_Queue + ACE_Message_Block *db, *hb; + int n; + + // Do an endless loop + for (;;) + { + db = new Message_Block (BUFSIZ); + hb = new Message_Block (sizeof (KEY), Message_Block::MB_PROTO, db); + + if ((n = this->peer_.recv (db->rd_ptr (), db->size ())) == -1) + LM_ERROR_RETURN ((LOG_ERROR, "%p", "recv failed"), -1); + else if (n == 0) // Client has closed down the connection. + { + if (this->router_task_->unbind_peer (this->get_handle ()) == -1) + LM_ERROR_RETURN ((LOG_ERROR, "%p", "unbind failed"), -1); + LM_DEBUG ((LOG_DEBUG, "(%t) shutting down \n")); + return -1; // We do not need to be deregistered by reactor + // as we were not registered at all + } + else + // Transform incoming buffer into a Message and pass + // downstream. + { + db->wr_ptr (n); + *(long *) hb->rd_ptr () = this->get_handle (); // Structure assignment. + hb->wr_ptr (sizeof (long)); + + if (this->router_task_->reply (hb) == -1) + { + cout << "Peer_Handler.svc : router_task->reply failed" << endl ; + return -1; + } + } + } + return 0; +#else + return -1; +#endif +} + +template <class ROUTER, class KEY> int +Peer_Handler<ROUTER, KEY>::put (ACE_Message_Block *mb, ACE_Time_Value *) +{ + return this->peer ().send_n (mb->rd_ptr (), mb->length ()); +} + +// Create a new handler and point its ROUTER_TASK_ data member to the +// corresponding router. Note that this router is extracted out of +// the Acceptor_Factory * that is passed in via the +// ACE_Acceptor::handle_input() method. + +template <class ROUTER, class KEY> int +Peer_Handler<ROUTER, KEY>::open (void *a) +{ + char buf[BUFSIZ], *p = buf; + + if (this->router_task_->info (&p, sizeof buf) != -1) + ACE_DEBUG ((LM_DEBUG, "(%t) creating handler for %s, fd = %d, this = %d\n", + buf, this->get_handle (), a)); + else + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "info"), -1); +#if 0 + if (this->activate (options.t_flags ()) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "activation of thread failed"), -1); +#endif + ACE_DEBUG ((LM_DEBUG, + "Peer_Handler::open registering with Reactor for handle_input\n")); + + if (ACE_Service_Config::reactor ()->register_handler + (this, ACE_Event_Handler::READ_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "register_handler"), -1); + else if (this->router_task_->bind_peer (this->get_handle (), this) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "bind_peer"), -1); + else if (this->peer ().disable (ACE_NONBLOCK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "disable non-blocking I/O"), -1); + return 0; +} + +// Receive a message from a supplier. + +template <class ROUTER, class KEY> int +Peer_Handler<ROUTER, KEY>::handle_input (ACE_HANDLE h) +{ + ACE_DEBUG ((LM_DEBUG, "(%t) input arrived on sd %d\n", h)); + + ACE_Message_Block *db = new ACE_Message_Block (BUFSIZ); + ACE_Message_Block *hb = new ACE_Message_Block (sizeof (KEY), + ACE_Message_Block::MB_PROTO, db); + int n; + + if ((n = this->peer ().recv (db->rd_ptr (), db->size ())) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p", "recv failed"), -1); + else if (n == 0) // Client has closed down the connection. + { + if (this->router_task_->unbind_peer (this->get_handle ()) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p", "unbind failed"), -1); + ACE_DEBUG ((LM_DEBUG, "(%t) shutting down %d\n", h)); + return -1; // Instruct the ACE_Reactor to deregister us by returning -1. + } + else // Transform incoming buffer into a Message and pass downstream. + { + db->wr_ptr (n); + *(ACE_HANDLE *) hb->rd_ptr () = this->get_handle (); // structure assignment. + hb->wr_ptr (sizeof (ACE_HANDLE)); + return this->router_task_->reply (hb) == -1 ? -1 : 0; + } +} + +template <class PH, class PK> +Peer_Router<PH, PK>::Peer_Router (ACE_Thread_Manager *tm) + : ACE_Task<ACE_MT_SYNCH> (tm) +{ +} + +template <class PH, class PK> int +Peer_Router<PH, PK>::send_peers (ACE_Message_Block *mb) +{ + PEER_ITERATOR map_iter = this->peer_map_; + int bytes = 0; + int iterations = 0; + ACE_Message_Block *data_block = mb->cont (); + + for (ACE_Map_Entry<PK, PH *> *ss = 0; + map_iter.next (ss) != 0; + map_iter.advance ()) + { + if (options.debug ()) + ACE_DEBUG ((LM_DEBUG, "(%t) sending to peer via sd %d\n", ss->ext_id_)); + + iterations++; + bytes += ss->int_id_->put (data_block); + } + + delete mb; + return bytes == 0 ? 0 : bytes / iterations; +} + +template <class PH, class PK> +Peer_Router<PH, PK>::~Peer_Router (void) +{ +} + +template <class PH, class PK> ACE_INLINE int +Peer_Router<PH, PK>::fini (void) +{ + delete this->acceptor_; + return 0; +} + +template <class PH, class PK> ACE_INLINE int +Peer_Router<PH, PK>::control (ACE_Message_Block *mb) +{ + ACE_IO_Cntl_Msg *ioc = (ACE_IO_Cntl_Msg *) mb->rd_ptr (); + ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds command; + + switch (command = ioc->cmd ()) + { + case ACE_IO_Cntl_Msg::SET_LWM: + case ACE_IO_Cntl_Msg::SET_HWM: + this->water_marks (command, *(size_t *) mb->cont ()->rd_ptr ()); + break; + default: + return -1; + } + return 0; +} + +template <class PH, class PK> ACE_INLINE int +Peer_Router<PH, PK>::unbind_peer (PK key) +{ + return this->peer_map_.unbind (key); +} + +template <class PH, class PK> ACE_INLINE int +Peer_Router<PH, PK>::bind_peer (PK key, Peer_Handler<Peer_Router<PH, PK>, PK> *ph) +{ + PH *peer_handler = (PH *) ph; + return this->peer_map_.bind (key, peer_handler); +} + +template <class PH, class PK> ACE_INLINE int +Peer_Router<PH, PK>::init (int argc, char *argv[]) +{ + this->acceptor_ = new ACCEPTOR (this); + + if (this->acceptor_->init (argc, argv) == -1 + || this->peer_map_.open () == -1) + return -1; + else + { + ACE_INET_Addr addr; + ACE_SOCK_Acceptor &acceptor = this->acceptor_->acceptor(); + + if (acceptor.get_local_addr (addr) != -1) + ACE_DEBUG ((LM_DEBUG, "(%t) initializing %s, port = %d, fd = %d, this = %u\n", + this->name (), addr.get_port_number (), + acceptor.get_handle (), this)); + else + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "get_local_addr"), -1); + } + return 0; +} + +#undef PH +#undef PA +#undef PAD +#undef PK +#undef PM +#endif /* ACE_HAS_THREADS */ +#endif /* _PEER_ROUTER_C */ diff --git a/examples/ASX/Event_Server/Event_Server/Peer_Router.h b/examples/ASX/Event_Server/Event_Server/Peer_Router.h new file mode 100644 index 00000000000..5df444a985a --- /dev/null +++ b/examples/ASX/Event_Server/Event_Server/Peer_Router.h @@ -0,0 +1,121 @@ +/* -*- C++ -*- */ +// @(#)Peer_Router.h 1.1 10/18/96 + + +#if !defined (_PEER_ROUTER_H) +#define _PEER_ROUTER_H + +#include "ace/Acceptor.h" +#include "ace/SOCK_Acceptor.h" +#include "ace/Thread_Manager.h" +#include "ace/Map_Manager.h" + +#if defined (ACE_HAS_THREADS) + +// Forward declaration. +template <class PEER_HANDLER, class KEY> +class Peer_Router; + +template <class PEER_HANDLER, class KEY> +class Acceptor_Factory : public ACE_Acceptor<PEER_HANDLER, ACE_SOCK_ACCEPTOR> + // = TITLE + // Creates <PEER_HANDLERs>, which route events between peers. +{ +public: + Acceptor_Factory (Peer_Router<PEER_HANDLER, KEY> *pr); + Peer_Router<PEER_HANDLER, KEY> *router (void); + + int init (int argc, char *argv[]); + // Initialize the acceptor when it's linked dynamically. + +private: + Peer_Router<PEER_HANDLER, KEY> *pr_; +}; + +template <class ROUTER, class KEY> +class Peer_Handler : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_MT_SYNCH> + // = TITLE + // Receive input from a Peer. +{ +public: + Peer_Handler (ACE_Thread_Manager * = 0); + + virtual int open (void * = 0); + // Called by the ACE_Acceptor::handle_input() to activate this object. + + virtual int handle_input (ACE_HANDLE); + // Receive input from the peer. + + virtual int put (ACE_Message_Block *, ACE_Time_Value *tv = 0); + // Send output to a peer. + +protected: + typedef ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_MT_SYNCH> inherited; + + ROUTER *router_task_; + // Pointer to write task. + +private: + virtual int svc (void); + // Don't need this method here... +}; + +template <class PEER_HANDLER, class PEER_KEY> +class Peer_Router : public ACE_Task<ACE_MT_SYNCH> + // = TITLE + // This abstract base class provides mechanisms for routing + // messages to/from a ACE_Stream from/to one or more peers (which + // are typically running on remote hosts). + // + // = DESCRIPTION + // A subclass of Peer_Router overrides the open(), close(), and + // put() methods in order to specialize the behavior of the router + // to meet application-specific requirements. +{ +public: + // = Initialization and termination methods. + Peer_Router (ACE_Thread_Manager * = 0); + ~Peer_Router (void); + + typedef Peer_Handler<Peer_Router<PEER_HANDLER, PEER_KEY>, PEER_KEY> HANDLER; + + virtual int unbind_peer (PEER_KEY); + // Remove a PEER_HANDLER from the PEER_MAP. + + virtual int bind_peer (PEER_KEY, HANDLER *); + // Add a PEER_HANDLER to the PEER_MAP + + int send_peers (ACE_Message_Block *mb); + // Send the message block to the peer(s). + +protected: + virtual int control (ACE_Message_Block *); + // Handle control messages arriving from adjacent Modules. + + // = Useful typedefs + typedef ACE_Map_Manager <PEER_KEY, PEER_HANDLER *, ACE_RW_Mutex> PEER_MAP; + typedef ACE_Map_Iterator<PEER_KEY, PEER_HANDLER *, ACE_RW_Mutex> PEER_ITERATOR; + + PEER_MAP peer_map_; + // Map used to keep track of active peers. + + // = Dynamic linking initialization hooks inherited from ACE_Task + virtual int init (int argc, char *argv[]); + virtual int fini (void); + + typedef Acceptor_Factory<PEER_HANDLER, PEER_KEY> ACCEPTOR; + + ACCEPTOR *acceptor_; + // Factory for accepting new PEER_HANDLERs. + +private: + // = Prevent copies and pass-by-value. + Peer_Router (const Peer_Router<PEER_HANDLER, PEER_KEY> &) {} + void operator= (const Peer_Router<PEER_HANDLER, PEER_KEY> &) {} +}; + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Peer_Router.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ +#endif /* ACE_HAS_THREADS */ +#endif /* _PEER_ROUTER_H */ diff --git a/examples/ASX/Event_Server/Event_Server/Supplier_Router.cpp b/examples/ASX/Event_Server/Event_Server/Supplier_Router.cpp new file mode 100644 index 00000000000..6d18dce66fa --- /dev/null +++ b/examples/ASX/Event_Server/Event_Server/Supplier_Router.cpp @@ -0,0 +1,134 @@ +#include "Supplier_Router.h" +// @(#)Supplier_Router.cpp 1.1 10/18/96 + +#include "Options.h" + +#if defined (ACE_HAS_THREADS) + +typedef Acceptor_Factory<Supplier_Handler, SUPPLIER_KEY> SUPPLIER_FACTORY; + +int +Supplier_Handler::open (void *a) +{ + SUPPLIER_FACTORY *af = (SUPPLIER_FACTORY *) a; + this->router_task_ = af->router (); + return this->Peer_Handler<SUPPLIER_ROUTER, SUPPLIER_KEY>::open (a); +} + +Supplier_Handler::Supplier_Handler (ACE_Thread_Manager *tm) + : Peer_Handler<SUPPLIER_ROUTER, SUPPLIER_KEY> (tm) +{ +} + +// Create a new router and associate it with the REACTOR parameter. + +Supplier_Router::Supplier_Router (ACE_Thread_Manager *tm) + : SUPPLIER_ROUTER (tm) +{ +} + +// Handle incoming messages in a separate thread. + +int +Supplier_Router::svc (void) +{ + assert (this->is_writer ()); + + ACE_Thread_Control tc (this->thr_mgr ()); + ACE_Message_Block *mb = 0; + + ACE_DEBUG ((LM_DEBUG, "(%t) starting svc in Supplier_Router\n")); + + while (this->getq (mb) >= 0) + { + ACE_DEBUG ((LM_DEBUG, "Supplier_Router is routing via send_peers\n")); + if (this->send_peers (mb) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "(%t) send_peers failed in Supplier_Router\n"), + -1); + } + + ACE_DEBUG ((LM_DEBUG, "(%t) stopping svc in Supplier_Router\n")); + return 0; + // Note the implicit ACE_OS::thr_exit() via ACE_Thread_Control's + // destructor. +} + +// Initialize the Router. + +int +Supplier_Router::open (void *) +{ + assert (this->is_writer ()); + + char *argv[4]; + + argv[0] = (char *) this->name (); + argv[1] = "-p"; + argv[2] = options.supplier_port (); + argv[3] = 0; + + if (this->init (2, &argv[1]) == -1) + return -1; + + // Make this an active object. + return this->activate (options.t_flags ()); +} + +// Close down the router. + +int +Supplier_Router::close (u_long) +{ + assert (this->is_writer ()); + ACE_DEBUG ((LM_DEBUG, "(%t) closing Supplier_Router\n")); + this->peer_map_.close (); + + // Inform the thread to shut down. + this->msg_queue ()->deactivate (); + return 0; +} + +// Send a MESSAGE_BLOCK to the supplier(s). + +int +Supplier_Router::put (ACE_Message_Block *mb, ACE_Time_Value *) +{ + assert (this->is_writer ()); + + if (mb->msg_type () == ACE_Message_Block::MB_IOCTL) + { + this->control (mb); + return this->put_next (mb); + } + else + // Queue up the message, which will be processed by + // Supplier_Router::svc(). + return this->putq (mb); +} + +// Return information about the Supplier_Router ACE_Module. + +int +Supplier_Router::info (char **strp, size_t length) const +{ + char buf[BUFSIZ]; + ACE_INET_Addr addr; + const char *mod_name = this->name (); + ACE_SOCK_Acceptor &sa = this->acceptor_->acceptor (); + + if (sa.get_local_addr (addr) == -1) + return -1; + + ACE_OS::sprintf (buf, "%s\t %d/%s %s", + mod_name, addr.get_port_number (), "tcp", + "# supplier router\n"); + + if (*strp == 0 && (*strp = ACE_OS::strdup (mod_name)) == 0) + return -1; + else + ACE_OS::strncpy (*strp, mod_name, length); + return ACE_OS::strlen (mod_name); +} + +#endif /* ACE_HAS_THREADS */ diff --git a/examples/ASX/Event_Server/Event_Server/Supplier_Router.h b/examples/ASX/Event_Server/Event_Server/Supplier_Router.h new file mode 100644 index 00000000000..766e08c01e3 --- /dev/null +++ b/examples/ASX/Event_Server/Event_Server/Supplier_Router.h @@ -0,0 +1,51 @@ +/* -*- C++ -*- */ +// @(#)Supplier_Router.h 1.1 10/18/96 + +/* The interface between a supplier and an Event Service ACE_Stream */ + +#if !defined (_SUPPLIER_ROUTER_H) +#define _SUPPLIER_ROUTER_H + +#include "ace/INET_Addr.h" +#include "ace/SOCK_Acceptor.h" +#include "ace/Map_Manager.h" +#include "ace/Svc_Handler.h" +#include "Peer_Router.h" + +#if defined (ACE_HAS_THREADS) + +/* Forward declaration */ +class Supplier_Handler; + +/* Type of search key for SUPPLIER_MAP */ +typedef ACE_HANDLE SUPPLIER_KEY; + +/* Instantiated type for routing messages to suppliers */ + +typedef Peer_Router<Supplier_Handler, SUPPLIER_KEY> SUPPLIER_ROUTER; + +class Supplier_Handler : public Peer_Handler<SUPPLIER_ROUTER, SUPPLIER_KEY> +{ +public: + Supplier_Handler (ACE_Thread_Manager *tm = 0); + virtual int open (void *); +}; + +class Supplier_Router : public SUPPLIER_ROUTER +{ +public: + Supplier_Router (ACE_Thread_Manager *); + +protected: + /* ACE_Task hooks. */ + virtual int open (void *a = 0); + virtual int close (u_long flags = 0); + virtual int put (ACE_Message_Block *msg, ACE_Time_Value * = 0); + virtual int svc (void); + + /* Dynamic linking hooks inherited from Peer_Router */ + virtual int info (char **info_string, size_t length) const; +}; + +#endif /* ACE_HAS_THREADS */ +#endif /* _SUPPLIER_ROUTER_H */ diff --git a/examples/ASX/Event_Server/Event_Server/event_server.cpp b/examples/ASX/Event_Server/Event_Server/event_server.cpp new file mode 100644 index 00000000000..e54bb845d84 --- /dev/null +++ b/examples/ASX/Event_Server/Event_Server/event_server.cpp @@ -0,0 +1,125 @@ +// Test the event server. +// @(#)event_server.cpp 1.1 10/18/96 + +#include "ace/Log_Msg.h" +#include "ace/Stream.h" +#include "ace/Service_Config.h" +#include "Options.h" +#include "Consumer_Router.h" +#include "Event_Analyzer.h" +#include "Supplier_Router.h" + +#if defined (ACE_HAS_THREADS) + +typedef ACE_Stream<ACE_MT_SYNCH> MT_Stream; +typedef ACE_Module<ACE_MT_SYNCH> MT_Module; + +// Handle SIGINT and terminate the entire application. + +class Quit_Handler : public ACE_Sig_Adapter +{ +public: + Quit_Handler (void); + virtual int handle_input (ACE_HANDLE fd); +}; + +Quit_Handler::Quit_Handler (void) + : ACE_Sig_Adapter (ACE_Sig_Handler_Ex (ACE_Service_Config::end_reactor_event_loop)) +{ + // Register to trap input from the user. + 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")); + // Register to trap the SIGINT signal. + else if (ACE_Service_Config::reactor ()->register_handler + (SIGINT, this) == -1) + ACE_ERROR ((LM_ERROR, "%p\n", "register_handler")); +} + +int +Quit_Handler::handle_input (ACE_HANDLE) +{ + options.stop_timer (); + ACE_DEBUG ((LM_INFO, "(%t) closing down the test\n")); + options.print_results (); + + ACE_Service_Config::end_reactor_event_loop (); + return 0; +} + +int +main (int argc, char *argv[]) +{ + ACE_Service_Config daemon; + + options.parse_args (argc, argv); + + { + // Primary ACE_Stream for EVENT_SERVER application. + MT_Stream event_server; + + // Enable graceful shutdowns... + Quit_Handler quit_handler; + + // Create the Supplier Router module. + + MT_Module *sr = new MT_Module ("Supplier_Router", + new Supplier_Router (ACE_Service_Config::thr_mgr ())); + + // Create the Event Analyzer module. + + MT_Module *ea = new MT_Module ("Event_Analyzer", + new Event_Analyzer, + new Event_Analyzer); + + // Create the Consumer Router module. + + MT_Module *cr = new MT_Module ("Consumer_Router", + 0, // 0 triggers the creation of a ACE_Thru_Task... + new Consumer_Router (ACE_Service_Config::thr_mgr ())); + + // Push the Modules onto the event_server stream. + + if (event_server.push (sr) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "push (Supplier_Router)"), -1); + + if (event_server.push (ea) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "push (Event_Analyzer)"), -1); + + if (event_server.push (cr) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "push (Consumer_Router)"), -1); + + // Set the high and low water marks appropriately. + + int wm = options.low_water_mark (); + + if (event_server.control (ACE_IO_Cntl_Msg::SET_LWM, &wm) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "push (setting low watermark)"), -1); + + wm = options.high_water_mark (); + if (event_server.control (ACE_IO_Cntl_Msg::SET_HWM, &wm) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "push (setting high watermark)"), -1); + + options.start_timer (); + + // Perform the main event loop waiting for the user to type ^C or to + // enter a line on the ACE_STDIN. + + daemon.run_reactor_event_loop (); + // The destructor of event_server will close down the stream and + // call the close() hooks on all the ACE_Tasks. + } + + // Wait for the threads to exit. + ACE_Service_Config::thr_mgr ()->wait (); + ACE_DEBUG ((LM_DEBUG, "exiting main\n")); + return 0; +} +#else +int +main (void) +{ + ACE_ERROR_RETURN ((LM_ERROR, "test not defined for this platform\n"), -1); +} +#endif /* ACE_HAS_THREADS */ diff --git a/examples/ASX/Event_Server/Makefile b/examples/ASX/Event_Server/Makefile new file mode 100644 index 00000000000..6c8d3f443f5 --- /dev/null +++ b/examples/ASX/Event_Server/Makefile @@ -0,0 +1,23 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the Event Server tests +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +DIRS = Event_Server \ + Transceiver + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nolocal.GNU + diff --git a/examples/ASX/Event_Server/README b/examples/ASX/Event_Server/README new file mode 100644 index 00000000000..f97e767cdd8 --- /dev/null +++ b/examples/ASX/Event_Server/README @@ -0,0 +1,38 @@ +The subdirectory illustrates a number of the ACE ASX framework +features using an ACE_Stream application called the Event Server. The +Event Server works as follows: + +1. When the ./Event_Server/event_server executable is run it + creates two SOCK_Acceptors, which listen for and accept + incoming connections from consumers and suppliers. + +2. The ./Event_Server/Transceiver/transceiver application may be + started multiple times. Each call should be either: + + % transceiver -p XYZ -h hostname + + or + + % transceiver -p ABC -h hostname + + where XYZ and ABC are the consumer port and supplier port, + respectively, on the event server and "hostname" is the name of the + machine the event_server is running. I typically open up multiple + windows. + +3. Once the consumer(s) and supplier(s) are connected, you can type + data from any supplier windows. This data will be routed + through the Modules/Tasks in an event_server's Stream and + be forwarded to the consumer(s). + +4. When you want to shut down the tranceivers or event server + just type ^C (which generates a SIGINT). + +What makes this example particularly interesting is that +once you've got the hang of this basic architecture, you can +"push" new filtering Modules onto the event_server Stream + and modify the application's behavior. + +For more information on the design and use of the ACE ASX framework +please see http://www.cs.wustl.edu/~schmidt/C++-USENIX-94.ps.gz and +http://www.cs.wustl.edu/~schmidt/DSEJ-94.ps.gz diff --git a/examples/ASX/Event_Server/Transceiver/Makefile b/examples/ASX/Event_Server/Transceiver/Makefile new file mode 100644 index 00000000000..7fb95dc617d --- /dev/null +++ b/examples/ASX/Event_Server/Transceiver/Makefile @@ -0,0 +1,135 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the transceiver portion of the Event Server test +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = transceiver + +LSRC = $(addsuffix .cpp,$(BIN)) + +LDLIBS = + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +INSTALL = + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.lib.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/transceiver.o .shobj/transceiver.so: transceiver.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Connector.h \ + $(WRAPPER_ROOT)/ace/Map_Manager.h \ + $(WRAPPER_ROOT)/ace/Map_Manager.cpp \ + $(WRAPPER_ROOT)/ace/Map_Manager.i \ + $(WRAPPER_ROOT)/ace/Svc_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch_Options.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Svc_Handler.cpp \ + $(WRAPPER_ROOT)/ace/Dynamic.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.i \ + $(WRAPPER_ROOT)/ace/Strategies.h \ + $(WRAPPER_ROOT)/ace/Strategies.cpp \ + $(WRAPPER_ROOT)/ace/Connector.i \ + $(WRAPPER_ROOT)/ace/Connector.cpp \ + $(WRAPPER_ROOT)/ace/SOCK_Connector.h \ + $(WRAPPER_ROOT)/ace/SOCK_Connector.i \ + $(WRAPPER_ROOT)/ace/Get_Opt.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/ASX/Event_Server/Transceiver/transceiver.cpp b/examples/ASX/Event_Server/Transceiver/transceiver.cpp new file mode 100644 index 00000000000..7321e02dd9c --- /dev/null +++ b/examples/ASX/Event_Server/Transceiver/transceiver.cpp @@ -0,0 +1,187 @@ +// Test program for the event transceiver. This program can play the +// @(#)transceiver.cpp 1.1 10/18/96 + +// role of either Consumer or Supplier. You can terminate this +// program by typing ^C.... + +#include "ace/Log_Msg.h" +#include "ace/Service_Config.h" +#include "ace/Connector.h" +#include "ace/SOCK_Connector.h" +#include "ace/Get_Opt.h" + +#if defined (ACE_HAS_THREADS) + +class Event_Transceiver : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> + // = TITLE + // Generate and receives messages from the event server. + // + // = DESCRIPTION + // This class is both a consumer and supplier of events, i.e., + // it is a ``transceiver.'' +{ +public: + Event_Transceiver (void); + + // = Svc_Handler hook called by the <ACE_Connector>. + virtual int open (void *); + // Initialize the transceiver when we are connected. + + // = Demultplexing hooks from the <ACE_Reactor>. + virtual int handle_input (ACE_HANDLE); + // Receive data from STDIN or socket. + + virtual int handle_signal (int signum, siginfo_t *, ucontext_t *); + // Close down via SIGINT. + +private: + int receiver (void); + // Reads data from socket and writes to ACE_STDOUT. + + int forwarder (void); + // Writes data from ACE_STDIN to socket. +}; + +// Close down via SIGINT. + +int +Event_Transceiver::handle_signal (int signum, + siginfo_t *, + ucontext_t *) +{ + ACE_DEBUG ((LM_DEBUG, "(%P|%t) received signal %S\n", signum)); + + ACE_Service_Config::end_reactor_event_loop (); + return 0; +} + +Event_Transceiver::Event_Transceiver (void) +{ + ACE_Sig_Set sig_set; + + sig_set.sig_add (SIGINT); + sig_set.sig_add (SIGQUIT); + + if (ACE_Service_Config::reactor ()->register_handler + (sig_set, this) == -1) + ACE_ERROR ((LM_ERROR, "%p\n", "register_handler")); +} + +int +Event_Transceiver::open (void *) +{ + if (ACE_Service_Config::reactor ()->register_handler + (this->peer ().get_handle (), + this, + ACE_Event_Handler::READ_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "register_handler"), -1); + else if (ACE::register_stdin_handler (this, + ACE_Service_Config::reactor (), + ACE_Service_Config::thr_mgr ()) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "register_stdin_handler"), -1); + return 0; +} + +int +Event_Transceiver::handle_input (ACE_HANDLE handle) +{ + if (handle == ACE_STDIN) + return this->forwarder (); + else + return this->receiver (); +} + + +int +Event_Transceiver::forwarder (void) +{ + ACE_DEBUG ((LM_DEBUG, "(%P|%t) entering transceiver forwarder\n")); + + char buf[BUFSIZ]; + ssize_t n = ACE_OS::read (ACE_STDIN, buf, sizeof buf); + int result = 0; + + if (n <= 0 || this->peer ().send_n (buf, n) != n) + result = -1; + + ACE_DEBUG ((LM_DEBUG, "(%P|%t) leaving transceiver forwarder\n")); + return result; +} + +int +Event_Transceiver::receiver (void) +{ + ACE_DEBUG ((LM_DEBUG, "(%P|%t) entering transceiver receiver\n")); + + char buf[BUFSIZ]; + + ssize_t n = this->peer ().recv (buf, sizeof buf); + int result = 0; + + if (n <= 0 || ACE_OS::write (ACE_STDOUT, buf, n) != n) + result = -1; + + ACE_DEBUG ((LM_DEBUG, "(%P|%t) leaving transceiver receiver\n")); + return result; +} + +// Port number of event server. +static u_short port_number; + +// Name of event server. +static char *host_name; + +// Handle the command-line arguments. + +static void +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opt (argc, argv, "h:p:"); + + port_number = ACE_DEFAULT_SERVER_PORT; + host_name = ACE_DEFAULT_SERVER_HOST; + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'h': + host_name = get_opt.optarg; + break; + case 'p': + port_number = ACE_OS::atoi (get_opt.optarg); + break; + default: + ACE_ERROR ((LM_ERROR, + "usage: %n [-p portnum] [-h host_name]\n%a", 1)); + /* NOTREACHED */ + break; + } +} + +int +main (int argc, char *argv[]) +{ + ACE_Service_Config daemon (argv[0]); + + parse_args (argc, argv); + + // Establish the connection. + ACE_Connector<Event_Transceiver, ACE_SOCK_CONNECTOR> connector; + Event_Transceiver transceiver; + + if (connector.connect (&transceiver, ACE_INET_Addr (port_number, host_name)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", host_name), 1); + + // Run event loop until either the event server shuts down or we get + // a SIGINT. + ACE_Service_Config::run_reactor_event_loop (); + return 0; +} +#else +int +main (void) +{ + ACE_ERROR ((LM_ERROR, "test not defined for this platform\n")); + return 0; +} +#endif /* ACE_HAS_THREADS */ diff --git a/examples/ASX/Makefile b/examples/ASX/Makefile new file mode 100644 index 00000000000..38b94b51626 --- /dev/null +++ b/examples/ASX/Makefile @@ -0,0 +1,25 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the ASX test directory +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +DIRS = CCM_App \ + Event_Server \ + Message_Queue \ + UPIPE_Event_Server + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nolocal.GNU + diff --git a/examples/ASX/Message_Queue/Makefile b/examples/ASX/Message_Queue/Makefile new file mode 100644 index 00000000000..77e32813526 --- /dev/null +++ b/examples/ASX/Message_Queue/Makefile @@ -0,0 +1,218 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for Message_Queue tests +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = buffer_stream \ + bounded_buffer \ + priority_buffer + +LSRC = $(addsuffix .cpp,$(BIN)) + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.lib.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/buffer_stream.o .shobj/buffer_stream.so: buffer_stream.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Stream.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Stream.cpp \ + $(WRAPPER_ROOT)/ace/Stream.i +.obj/bounded_buffer.o .shobj/bounded_buffer.so: bounded_buffer.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h +.obj/priority_buffer.o .shobj/priority_buffer.so: priority_buffer.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Read_Buffer.h \ + $(WRAPPER_ROOT)/ace/Read_Buffer.i \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/ASX/Message_Queue/bounded_buffer.cpp b/examples/ASX/Message_Queue/bounded_buffer.cpp new file mode 100644 index 00000000000..ec5abd1d7e1 --- /dev/null +++ b/examples/ASX/Message_Queue/bounded_buffer.cpp @@ -0,0 +1,130 @@ +// This short program copies stdin to stdout via the use of an ASX +// @(#)bounded_buffer.cpp 1.1 10/18/96 + +// Message_Queue. It illustrates an implementation of the classic +// "bounded buffer" program. + +#include "ace/Log_Msg.h" +#include "ace/Message_Queue.h" +#include "ace/Thread_Manager.h" + +#if defined (ACE_HAS_THREADS) + +// Global thread manager. +static ACE_Thread_Manager thr_mgr; + +// Message list. +static ACE_Message_Queue<ACE_MT_SYNCH> msg_queue; + +// The producer reads data from the stdin stream, creates a message, +// and then queues the message in the message list, where it is +// removed by the consumer thread. A 0-sized message is enqueued when +// there is no more data to read. The consumer uses this as a flag to +// know when to exit. + +static void * +producer (ACE_Message_Queue<ACE_MT_SYNCH> *msg_queue) +{ + // Insert thread into thr_mgr. + ACE_Thread_Control thread_control (&thr_mgr); + + // Keep reading stdin, until we reach EOF. + + for (int n; ; ) + { + // Allocate a new message. + ACE_Message_Block *mb = new ACE_Message_Block (BUFSIZ); + + n = ACE_OS::read (ACE_STDIN, mb->rd_ptr (), mb->size ()); + + if (n <= 0) + { + // Send a shutdown message to the other thread and exit. + mb->length (0); + if (msg_queue->enqueue_tail (mb) == -1) + ACE_ERROR ((LM_ERROR, "(%t) %p\n", "put_next")); + break; + } + + // Send the message to the other thread. + else + { + mb->msg_priority (n); + mb->wr_ptr (n); + if (msg_queue->enqueue_tail (mb) == -1) + ACE_ERROR ((LM_ERROR, "(%t) %p\n", "put_next")); + } + } + + // The destructor of ACE_Thread_Control removes the exiting thread + // from the thr_mgr automatically. + return 0; +} + +// The consumer dequeues a message from the ACE_Message_Queue, writes +// the message to the stderr stream, and deletes the message. The +// producer sends a 0-sized message to inform the consumer to stop +// reading and exit. + +static void *consumer (ACE_Message_Queue<ACE_MT_SYNCH> *msg_queue) +{ + // Insert thread into thr_mgr. + ACE_Thread_Control thread_control (&thr_mgr); + int result = 0; + + // Keep looping, reading a message out of the queue, until we timeout + // or get a message with a length == 0, which signals us to quit. + + for (;;) + { + ACE_Message_Block *mb; + + ACE_Time_Value timeout (ACE_OS::time (0) + 4, 0); // Wait for upto 4 seconds + + result = msg_queue->dequeue_head (mb, &timeout); + + if (result == -1) + break; + + int length = mb->length (); + + if (length > 0) + ACE_OS::write (ACE_STDOUT, mb->rd_ptr (), length); + + delete mb; + + if (length == 0) + break; + } + + if (result == -1 && errno == EWOULDBLOCK) + ACE_ERROR ((LM_ERROR, "(%t) %p\n%a", "timed out waiting for message", 1)); + + // The destructor of ACE_Thread_Control removes the exiting thread + // from the thr_mgr automatically. + return 0; +} + +/* Spawn off two threads that copy stdin to stdout. */ + +int main (int, char *[]) +{ + if (thr_mgr.spawn (ACE_THR_FUNC (producer), (void *) &msg_queue, + THR_NEW_LWP | THR_DETACHED) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), 1); + else if (thr_mgr.spawn (ACE_THR_FUNC (consumer), (void *) &msg_queue, + THR_NEW_LWP | THR_DETACHED) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), 1); + + // Wait for producer and consumer threads to exit. + thr_mgr.wait (); + return 0; +} +#else +int +main (int, char *[]) +{ + ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); + return 0; +} +#endif /* ACE_HAS_THREADS */ diff --git a/examples/ASX/Message_Queue/buffer_stream.cpp b/examples/ASX/Message_Queue/buffer_stream.cpp new file mode 100644 index 00000000000..0cc96cd16c5 --- /dev/null +++ b/examples/ASX/Message_Queue/buffer_stream.cpp @@ -0,0 +1,215 @@ +// This short program copies stdin to stdout via the use of an ASX +// @(#)buffer_stream.cpp 1.1 10/18/96 + +// STREAM. It illustrates an implementation of the classic "bounded +// buffer" program using an ASX STREAM containing two Modules. Each +// ACE_Module contains two Tasks. Each ACE_Task contains a +// ACE_Message_Queue and a pointer to a ACE_Thread_Manager. Note how +// the use of these reusable components reduces the reliance on global +// variables, as compared with the bounded_buffer.C example. + +#include "ace/Log_Msg.h" +#include "ace/Synch.h" +#include "ace/Service_Config.h" +#include "ace/Stream.h" +#include "ace/Module.h" +#include "ace/Task.h" + +#if defined (ACE_HAS_THREADS) + +typedef ACE_Stream<ACE_MT_SYNCH> MT_Stream; +typedef ACE_Module<ACE_MT_SYNCH> MT_Module; +typedef ACE_Task<ACE_MT_SYNCH> MT_Task; + +class Common_Task : public MT_Task + // = TITLE + // Methods that are common to the producer and consumer. +{ +public: + Common_Task (void) {} + // ACE_Task hooks + virtual int open (void * = 0); + virtual int close (u_long = 0); + virtual int put (ACE_Message_Block *, ACE_Time_Value * = 0) { return 0; } + + // ACE_Service_Object hooks + virtual int init (int, char **) { return 0; } + virtual int fini (void) { return 0; } + virtual int info (char **, size_t) const { return 0; } +}; + +// Define the Producer interface. + +class Producer : public Common_Task +{ +public: + Producer (void) {} + + // Read data from stdin and pass to consumer. + virtual int svc (void); +}; + +class Consumer : public Common_Task + // = TITLE + // Define the Consumer interface. +{ +public: + Consumer (void) {} + + // Enqueue the message on the ACE_Message_Queue for subsequent + // handling in the svc() method. + virtual int put (ACE_Message_Block *mb, ACE_Time_Value *tv = 0); + + // Receive message from producer and print to stdout. + virtual int svc (void); + +private: + + ACE_Time_Value timeout_; +}; + +// Spawn off a new thread. + +int +Common_Task::open (void *) +{ + if (this->activate (THR_NEW_LWP | THR_DETACHED) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), -1); + return 0; +} + +int +Common_Task::close (u_long exit_status) +{ + ACE_DEBUG ((LM_DEBUG, "(%t) thread is exiting with status %d in module %s\n", + exit_status, this->name ())); + + // Can do anything here that is required when a thread exits, e.g., + // storing thread-specific information in some other storage + // location, etc. + return 0; +} + +// The Consumer reads data from the stdin stream, creates a message, +// and then queues the message in the message list, where it is +// removed by the consumer thread. A 0-sized message is enqueued when +// there is no more data to read. The consumer uses this as a flag to +// know when to exit. + +int +Producer::svc (void) +{ + // Keep reading stdin, until we reach EOF. + + for (int n; ; ) + { + // Allocate a new message. + ACE_Message_Block *mb = new ACE_Message_Block (BUFSIZ); + + n = ACE_OS::read (ACE_STDIN, mb->rd_ptr (), mb->size ()); + + if (n <= 0) + { + // Send a shutdown message to the other thread and exit. + mb->length (0); + + if (this->put_next (mb) == -1) + ACE_ERROR ((LM_ERROR, "(%t) %p\n", "put_next")); + break; + } + + // Send the message to the other thread. + else + { + mb->wr_ptr (n); + + if (this->put_next (mb) == -1) + ACE_ERROR ((LM_ERROR, "(%t) %p\n", "put_next")); + } + } + + return 0; +} + +// Simply enqueue the Message_Block into the end of the queue. + +int +Consumer::put (ACE_Message_Block *mb, ACE_Time_Value *tv) +{ + return this->putq (mb, tv); +} + +// The consumer dequeues a message from the ACE_Message_Queue, writes +// the message to the stderr stream, and deletes the message. The +// Consumer sends a 0-sized message to inform the consumer to stop +// reading and exit. + +int +Consumer::svc (void) +{ + int result = 0; + + // Keep looping, reading a message out of the queue, until we + // timeout or get a message with a length == 0, which signals us to + // quit. + + for (;;) + { + ACE_Message_Block *mb; + + this->timeout_.sec (ACE_OS::time (0) + 4); // Wait for upto 4 seconds + + result = this->getq (mb, &this->timeout_); + + if (result == -1) + break; + + int length = mb->length (); + + if (length > 0) + ACE_OS::write (ACE_STDOUT, mb->rd_ptr (), length); + + delete mb; + + if (length == 0) + break; + } + + if (result == -1 && errno == EWOULDBLOCK) + ACE_ERROR ((LM_ERROR, "(%t) %p\n%a", "timed out waiting for message", 1)); + return 0; +} + +// Main driver function. + +int +main (int argc, char *argv[]) +{ + ACE_Service_Config daemon (argv[0]); + + // Control hierachically-related active objects + MT_Stream stream; + MT_Module *pm = new MT_Module ("Consumer", new Consumer); + MT_Module *cm = new MT_Module ("Producer", new Producer); + + // Create Producer and Consumer Modules and push them onto the + // STREAM. All processing is performed in the STREAM. + + if (stream.push (pm) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "push"), 1); + else if (stream.push (cm) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "push"), 1); + + // Barrier synchronization: wait for the threads to exit, then exit + // ourselves. + ACE_Service_Config::thr_mgr ()->wait (); + return 0; +} +#else +int +main (int, char *[]) +{ + ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); + return 0; +} +#endif /* ACE_HAS_THREADS */ diff --git a/examples/ASX/Message_Queue/priority_buffer.cpp b/examples/ASX/Message_Queue/priority_buffer.cpp new file mode 100644 index 00000000000..ef59d76b355 --- /dev/null +++ b/examples/ASX/Message_Queue/priority_buffer.cpp @@ -0,0 +1,139 @@ +// This short program prints the contents of stdin to stdout sorted by +// @(#)priority_buffer.cpp 1.1 10/18/96 + +// the length of each line via the use of an ASX Message_Queue. It +// illustrates how priorities can be used for ACE Message_Queues. + +#include "ace/Log_Msg.h" +#include "ace/Message_Queue.h" +#include "ace/Read_Buffer.h" +#include "ace/Thread_Manager.h" +#include "ace/Service_Config.h" + +#if defined (ACE_HAS_THREADS) + +// Global thread manager. +static ACE_Thread_Manager thr_mgr; + +// Make the queue be capable of being *very* large. +static const long max_queue = LONG_MAX; + +// Message queue. +static ACE_Message_Queue<ACE_MT_SYNCH> msg_queue (max_queue); + +// The consumer dequeues a message from the ACE_Message_Queue, writes +// the message to the stderr stream, and deletes the message. The +// producer sends a 0-sized message to inform the consumer to stop +// reading and exit. + +static void * +consumer (ACE_Message_Queue<ACE_MT_SYNCH> *msg_queue) +{ + // Keep looping, reading a message out of the queue, until we + // timeout or get a message with a length == 0, which signals us to + // quit. + + for (;;) + { + ACE_Message_Block *mb; + + if (msg_queue->dequeue_head (mb) == -1) + break; + + int length = mb->length (); + + if (length > 0) + ACE_OS::puts (mb->rd_ptr ()); + + // Free up the buffer memory and the Message_Block. + ACE_Service_Config::allocator ()->free (mb->rd_ptr ()); + delete mb; + + if (length == 0) + break; + } + + return 0; +} + +// The producer reads data from the stdin stream, creates a message, +// and then queues the message in the message list, where it is +// removed by the consumer thread. A 0-sized message is enqueued when +// there is no more data to read. The consumer uses this as a flag to +// know when to exit. + +static void * +producer (ACE_Message_Queue<ACE_MT_SYNCH> *msg_queue) +{ + // Insert thread into thr_mgr. + ACE_Thread_Control thread_control (&thr_mgr); + + ACE_Read_Buffer rb (ACE_STDIN); + + // Keep reading stdin, until we reach EOF. + + for (int n; ; ) + { + // Allocate a new buffer. + char *buffer = rb.read ('\n'); + + if (buffer == 0) + { + // Send a 0-sized shutdown message to the other thread and + // exit. + if (msg_queue->enqueue_tail (new ACE_Message_Block ((size_t) 0)) == -1) + ACE_ERROR ((LM_ERROR, "(%t) %p\n", "put_next")); + break; + } + + // Enqueue the message in priority order. + else + { + // Allocate a new message, but have it "borrow" its memory + // from the buffer. + ACE_Message_Block *mb = new ACE_Message_Block (rb.size (), + ACE_Message_Block::MB_DATA, + 0, + buffer); + mb->msg_priority (rb.size ()); + mb->wr_ptr (rb.size ()); + + ACE_DEBUG ((LM_DEBUG, "enqueueing message of size %d\n", + mb->msg_priority ())); + // Enqueue in priority order. + if (msg_queue->enqueue (mb) == -1) + ACE_ERROR ((LM_ERROR, "(%t) %p\n", "put_next")); + } + } + + // Now read all the items out in priority order (i.e., ordered by + // the size of the lines!). + consumer (msg_queue); + + // The destructor of ACE_Thread_Control removes the exiting thread + // from the thr_mgr automatically. + return 0; +} + +// Spawn off one thread that copies stdin to stdout in order of the +// size of each line. + +int +main (int, char *[]) +{ + if (thr_mgr.spawn (ACE_THR_FUNC (producer), (void *) &msg_queue, + THR_NEW_LWP | THR_DETACHED) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), 1); + + // Wait for producer and consumer threads to exit. + thr_mgr.wait (); + return 0; +} +#else +int +main (int, char *[]) +{ + ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); + return 0; +} +#endif /* ACE_HAS_THREADS */ diff --git a/examples/ASX/UPIPE_Event_Server/Consumer_Router.cpp b/examples/ASX/UPIPE_Event_Server/Consumer_Router.cpp new file mode 100644 index 00000000000..e679de5390e --- /dev/null +++ b/examples/ASX/UPIPE_Event_Server/Consumer_Router.cpp @@ -0,0 +1,126 @@ +#include "Consumer_Router.h" +// @(#)Consumer_Router.cpp 1.1 10/18/96 + +#include "Options.h" + +#if defined (ACE_HAS_THREADS) + +typedef Acceptor_Factory<Consumer_Handler, CONSUMER_KEY> CONSUMER_FACTORY; + +int +Consumer_Handler::open (void *a) +{ + CONSUMER_FACTORY *af = (CONSUMER_FACTORY *) a; + this->router_task_ = af->router (); + return this->Peer_Handler<CONSUMER_ROUTER, CONSUMER_KEY>::open (a); +} + +Consumer_Handler::Consumer_Handler (ACE_Thread_Manager *tm) + : Peer_Handler<CONSUMER_ROUTER, CONSUMER_KEY> (tm) +{ +} + +// Create a new handler that will interact with a consumer and point +// its ROUTER_TASK_ data member to the CONSUMER_ROUTER. + +Consumer_Router::Consumer_Router (ACE_Thread_Manager *tm) + : CONSUMER_ROUTER (tm) +{ +} + +// Initialize the Router.. + +int +Consumer_Router::open (void *) +{ + ACE_ASSERT (this->is_reader ()); + char *argv[3]; + + argv[0] = (char *) this->name (); + argv[1] = options.consumer_file (); + argv[2] = 0; + + if (this->init (1, &argv[1]) == -1) + return -1; + + // Make this an active object. +// return this->activate (options.t_flags ()); +} + +int +Consumer_Router::close (u_long) +{ + ACE_ASSERT (this->is_reader ()); + this->peer_map_.close (); + this->msg_queue ()->deactivate(); + return 0; +} + + +// Handle incoming messages in a separate thread.. + +int +Consumer_Router::svc (void) +{ + ACE_Thread_Control tc (this->thr_mgr ()); + ACE_Message_Block *mb = 0; + + ACE_ASSERT (this->is_reader ()); + + if (options.debug ()) + ACE_DEBUG ((LM_DEBUG, "(%t) starting svc in %s\n", this->name ())); + + while (this->getq (mb) > 0) + { + if (this->put_next (mb) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "(%t) put_next failed in %s\n", this->name ()), -1); + + } + return 0; + // Note the implicit ACE_OS::thr_exit() via destructor. +} + +// Send a MESSAGE_BLOCK to the supplier(s).. + +int +Consumer_Router::put (ACE_Message_Block *mb, ACE_Time_Value *) +{ + ACE_ASSERT (this->is_reader ()); + + if (mb->msg_type () == ACE_Message_Block::MB_IOCTL) + { + this->control (mb); + return this->put_next (mb); + } + else +{ +//printf("consumer-Router is routing : send_peers\n"); + return this->send_peers (mb); +} +} + +// Return information about the Client_Router ACE_Module.. + +int +Consumer_Router::info (char **strp, size_t length) const +{ + char buf[BUFSIZ]; + ACE_UPIPE_Addr addr; + const char *mod_name = this->name (); + ACE_UPIPE_Acceptor &sa = (ACE_UPIPE_Acceptor &) *this->acceptor_; + + if (sa.get_local_addr (addr) == -1) + return -1; + + ACE_OS::sprintf (buf, "%s\t /%s %s", + mod_name, "upipe", + "# consumer router\n"); + + if (*strp == 0 && (*strp = ACE_OS::strdup (mod_name)) == 0) + return -1; + else + ACE_OS::strncpy (*strp, mod_name, length); + return ACE_OS::strlen (mod_name); +} + +#endif /* ACE_HAS_THREADS */ diff --git a/examples/ASX/UPIPE_Event_Server/Consumer_Router.h b/examples/ASX/UPIPE_Event_Server/Consumer_Router.h new file mode 100644 index 00000000000..66d3f28ba07 --- /dev/null +++ b/examples/ASX/UPIPE_Event_Server/Consumer_Router.h @@ -0,0 +1,48 @@ +/* -*- C++ -*- */ +// @(#)Consumer_Router.h 1.1 10/18/96 + +// The interface between one or more consumers and an Event Server +// ACE_Stream. + +#if !defined (_CONSUMER_ROUTER_H) +#define _CONSUMER_ROUTER_H + +#include "ace/Thread_Manager.h" +#include "ace/UPIPE_Acceptor.h" +#include "ace/UPIPE_Addr.h" +#include "ace/Svc_Handler.h" +#include "Peer_Router.h" + +#if defined (ACE_HAS_THREADS) + +class Consumer_Handler; // Forward declaration.... + +typedef long CONSUMER_KEY; + +typedef Peer_Router<Consumer_Handler, CONSUMER_KEY> CONSUMER_ROUTER; + +class Consumer_Handler + : public Peer_Handler<CONSUMER_ROUTER, CONSUMER_KEY> +{ +public: + Consumer_Handler (ACE_Thread_Manager *tm = 0); + virtual int open (void *); +}; + +class Consumer_Router : public CONSUMER_ROUTER +{ +public: + Consumer_Router (ACE_Thread_Manager *thr_manager); + +protected: + // ACE_Task hooks.. + virtual int open (void *a = 0); + virtual int close (u_long flags = 0); + virtual int put (ACE_Message_Block *msg, ACE_Time_Value * = 0); + virtual int svc (void); + + // Dynamic linking hooks. + virtual int info (char **info_string, size_t length) const; +}; +#endif /* ACE_HAS_THREADS */ +#endif /* _CONSUMER_ROUTER_H */ diff --git a/examples/ASX/UPIPE_Event_Server/Event_Analyzer.cpp b/examples/ASX/UPIPE_Event_Server/Event_Analyzer.cpp new file mode 100644 index 00000000000..977e5c4af9d --- /dev/null +++ b/examples/ASX/UPIPE_Event_Server/Event_Analyzer.cpp @@ -0,0 +1,68 @@ +#include "Event_Analyzer.h" +// @(#)Event_Analyzer.cpp 1.1 10/18/96 + + +#if defined (ACE_HAS_THREADS) + +int +Event_Analyzer::open (void *) +{ + return 0; +} + +int +Event_Analyzer::close (u_long) +{ + return 0; +} + +int +Event_Analyzer::control (ACE_Message_Block *mb) +{ + ACE_IO_Cntl_Msg *ioc = (ACE_IO_Cntl_Msg *) mb->rd_ptr (); + ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd; + + switch (cmd = ioc->cmd ()) + { + case ACE_IO_Cntl_Msg::SET_LWM: + case ACE_IO_Cntl_Msg::SET_HWM: + this->water_marks (cmd, *(size_t *) mb->cont ()->rd_ptr ()); + break; + } + return 0; +} + +int +Event_Analyzer::put (ACE_Message_Block *mb, ACE_Time_Value *) +{ + if (mb->msg_type () == ACE_Message_Block::MB_IOCTL) + this->control (mb); + + return this->put_next (mb); +} + +int +Event_Analyzer::init (int, char *[]) +{ + return 0; +} + +int +Event_Analyzer::fini (void) +{ + return 0; +} + +int +Event_Analyzer::info (char **strp, size_t length) const +{ + const char *mod_name = this->name (); + + if (*strp == 0 && (*strp = ACE_OS::strdup (mod_name)) == 0) + return -1; + else + ACE_OS::strncpy (*strp, mod_name, length); + return ACE_OS::strlen (mod_name); +} + +#endif /* ACE_HAS_THREADS */ diff --git a/examples/ASX/UPIPE_Event_Server/Event_Analyzer.h b/examples/ASX/UPIPE_Event_Server/Event_Analyzer.h new file mode 100644 index 00000000000..30053d5f45d --- /dev/null +++ b/examples/ASX/UPIPE_Event_Server/Event_Analyzer.h @@ -0,0 +1,34 @@ +/* -*- C++ -*- */ +// @(#)Event_Analyzer.h 1.1 10/18/96 + +// Signal router. + +#if !defined (_EVENT_ANALYZER_H) +#define _EVENT_ANALYZER_H + +#include "ace/Stream.h" +#include "ace/Module.h" +#include "ace/Task.h" +#include "ace/Synch.h" + +#if defined (ACE_HAS_THREADS) + +class Event_Analyzer : public ACE_Task<ACE_MT_SYNCH> +{ +public: + virtual int open (void *a = 0); + virtual int close (u_long flags = 0); + virtual int put (ACE_Message_Block *msg, ACE_Time_Value * = 0); + virtual int svc (void) { return 0; } + + // Dynamic linking hooks. + virtual int init (int argc, char *argv[]); + virtual int fini (void); + virtual int info (char **info_string, size_t length) const; + +private: + virtual int control (ACE_Message_Block *); +}; + +#endif /* ACE_HAS_THREADS */ +#endif /* _EVENT_ANALYZER_H */ diff --git a/examples/ASX/UPIPE_Event_Server/Makefile b/examples/ASX/UPIPE_Event_Server/Makefile new file mode 100644 index 00000000000..bb0cdc00ed4 --- /dev/null +++ b/examples/ASX/UPIPE_Event_Server/Makefile @@ -0,0 +1,455 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the Event Server test +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = event_server + +FILES = Options \ + Supplier_Router \ + Event_Analyzer \ + Consumer_Router \ + Peer_Router + +LSRC = $(addsuffix .cpp,$(FILES)) +LOBJ = $(addsuffix .o,$(FILES)) +SHOBJ = $(addsuffix .so,$(FILES)) + +LDLIBS = $(addprefix .shobj/,$(SHOBJ)) + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.lib.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/Options.o .shobj/Options.so: Options.cpp \ + $(WRAPPER_ROOT)/ace/Get_Opt.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + Options.h \ + $(WRAPPER_ROOT)/ace/Profile_Timer.h \ + Options.i +.obj/Supplier_Router.o .shobj/Supplier_Router.so: Supplier_Router.cpp Supplier_Router.h \ + $(WRAPPER_ROOT)/ace/UPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/UPIPE_Acceptor.h \ + $(WRAPPER_ROOT)/ace/UPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/Stream.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Stream.cpp \ + $(WRAPPER_ROOT)/ace/Stream.i \ + $(WRAPPER_ROOT)/ace/SPIPE.h \ + $(WRAPPER_ROOT)/ace/SPIPE.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Acceptor.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.i \ + $(WRAPPER_ROOT)/ace/UPIPE_Acceptor.i \ + $(WRAPPER_ROOT)/ace/Map_Manager.h \ + $(WRAPPER_ROOT)/ace/Map_Manager.cpp \ + $(WRAPPER_ROOT)/ace/Map_Manager.i \ + $(WRAPPER_ROOT)/ace/Svc_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch_Options.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.cpp \ + $(WRAPPER_ROOT)/ace/Dynamic.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.i \ + Peer_Router.h \ + $(WRAPPER_ROOT)/ace/Acceptor.h \ + $(WRAPPER_ROOT)/ace/Strategies.h \ + $(WRAPPER_ROOT)/ace/Strategies.cpp \ + $(WRAPPER_ROOT)/ace/Acceptor.i \ + $(WRAPPER_ROOT)/ace/Acceptor.cpp \ + Peer_Router.cpp \ + $(WRAPPER_ROOT)/ace/Get_Opt.h \ + Options.h \ + $(WRAPPER_ROOT)/ace/Profile_Timer.h \ + Options.i +.obj/Event_Analyzer.o .shobj/Event_Analyzer.so: Event_Analyzer.cpp Event_Analyzer.h \ + $(WRAPPER_ROOT)/ace/Stream.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Stream.cpp \ + $(WRAPPER_ROOT)/ace/Stream.i +.obj/Consumer_Router.o .shobj/Consumer_Router.so: Consumer_Router.cpp Consumer_Router.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/UPIPE_Acceptor.h \ + $(WRAPPER_ROOT)/ace/UPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/Stream.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Stream.cpp \ + $(WRAPPER_ROOT)/ace/Stream.i \ + $(WRAPPER_ROOT)/ace/SPIPE.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/SPIPE.i \ + $(WRAPPER_ROOT)/ace/UPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Acceptor.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.i \ + $(WRAPPER_ROOT)/ace/UPIPE_Acceptor.i \ + $(WRAPPER_ROOT)/ace/Svc_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch_Options.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.cpp \ + $(WRAPPER_ROOT)/ace/Dynamic.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.i \ + Peer_Router.h \ + $(WRAPPER_ROOT)/ace/Acceptor.h \ + $(WRAPPER_ROOT)/ace/Strategies.h \ + $(WRAPPER_ROOT)/ace/Strategies.cpp \ + $(WRAPPER_ROOT)/ace/Acceptor.i \ + $(WRAPPER_ROOT)/ace/Acceptor.cpp \ + $(WRAPPER_ROOT)/ace/Map_Manager.h \ + $(WRAPPER_ROOT)/ace/Map_Manager.cpp \ + $(WRAPPER_ROOT)/ace/Map_Manager.i \ + Peer_Router.cpp \ + $(WRAPPER_ROOT)/ace/Get_Opt.h \ + Options.h \ + $(WRAPPER_ROOT)/ace/Profile_Timer.h \ + Options.i +.obj/Peer_Router.o .shobj/Peer_Router.so: Peer_Router.cpp \ + $(WRAPPER_ROOT)/ace/Get_Opt.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + Peer_Router.h \ + $(WRAPPER_ROOT)/ace/Acceptor.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch_Options.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Svc_Handler.cpp \ + $(WRAPPER_ROOT)/ace/Dynamic.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.i \ + $(WRAPPER_ROOT)/ace/Strategies.h \ + $(WRAPPER_ROOT)/ace/Strategies.cpp \ + $(WRAPPER_ROOT)/ace/Acceptor.i \ + $(WRAPPER_ROOT)/ace/Acceptor.cpp \ + $(WRAPPER_ROOT)/ace/UPIPE_Acceptor.h \ + $(WRAPPER_ROOT)/ace/UPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/Stream.h \ + $(WRAPPER_ROOT)/ace/Stream.cpp \ + $(WRAPPER_ROOT)/ace/Stream.i \ + $(WRAPPER_ROOT)/ace/SPIPE.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/SPIPE.i \ + $(WRAPPER_ROOT)/ace/UPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Acceptor.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.i \ + $(WRAPPER_ROOT)/ace/UPIPE_Acceptor.i \ + $(WRAPPER_ROOT)/ace/Map_Manager.h \ + $(WRAPPER_ROOT)/ace/Map_Manager.cpp \ + $(WRAPPER_ROOT)/ace/Map_Manager.i \ + Peer_Router.cpp Options.h \ + $(WRAPPER_ROOT)/ace/Profile_Timer.h \ + Options.i + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/ASX/UPIPE_Event_Server/Options.cpp b/examples/ASX/UPIPE_Event_Server/Options.cpp new file mode 100644 index 00000000000..2a334d7ff2a --- /dev/null +++ b/examples/ASX/UPIPE_Event_Server/Options.cpp @@ -0,0 +1,191 @@ +#include "ace/Get_Opt.h" +// @(#)Options.cpp 1.1 10/18/96 + +#include "ace/Synch.h" +#include "ace/Log_Msg.h" +#include "Options.h" + +#if defined (ACE_HAS_THREADS) + +Options::Options (void) + : debugging_ (0), + verbosity_ (0), + low_water_mark_ (1024), + high_water_mark_ (8 * 1024), + message_size_ (128), + thr_count_ (4), + initial_queue_length_ (0), + iterations_ (100000), + consumer_port_ ("-p 10000"), + supplier_port_ ("-p 10001"), + consumer_file_ ("-f/tmp/conupipe"), + supplier_file_ ("-f/tmp/supupipe"), + t_flags_ (THR_DETACHED) +{ +} + +Options::~Options (void) +{ +} + +void Options::print_results (void) +{ + ACE_Profile_Timer::ACE_Elapsed_Time et; + this->itimer_.elapsed_time (et); + +#if defined (ACE_HAS_PRUSAGE_T) + prusage_t rusage; + this->itimer_.get_rusage (rusage); + + if (options.verbose ()) + { + ACE_OS::printf ("final concurrency hint = %d\n", ACE_OS::thr_getconcurrency ()); + ACE_OS::printf ("%8d = lwpid\n" + "%8d = lwp count\n" + "%8d = minor page faults\n" + "%8d = major page faults\n" + "%8d = input blocks\n" + "%8d = output blocks\n" + "%8d = messages sent\n" + "%8d = messages received\n" + "%8d = signals received\n" + "%8ds, %dms = wait-cpu (latency) time\n" + "%8ds, %dms = user lock wait sleep time\n" + "%8ds, %dms = all other sleep time\n" + "%8d = voluntary context switches\n" + "%8d = involuntary context switches\n" + "%8d = system calls\n" + "%8d = chars read/written\n", + rusage.pr_lwpid, + rusage.pr_count, + rusage.pr_minf, + rusage.pr_majf, + rusage.pr_inblk, + rusage.pr_oublk, + rusage.pr_msnd, + rusage.pr_mrcv, + rusage.pr_sigs, + rusage.pr_wtime.tv_sec, rusage.pr_wtime.tv_nsec / 1000000, + rusage.pr_ltime.tv_sec, rusage.pr_ltime.tv_nsec / 1000000, + rusage.pr_slptime.tv_sec, rusage.pr_slptime.tv_nsec / 1000000, + rusage.pr_vctx, + rusage.pr_ictx, + rusage.pr_sysc, + rusage.pr_ioch); + } +#endif /* ACE_HAS_PRUSAGE_T */ + + ACE_OS::printf ("---------------------\n" + "real time = %.3f\n" + "user time = %.3f\n" + "system time = %.3f\n" + "---------------------\n", + et.real_time, et.user_time, et.system_time); +} + +// Manages the options. +Options options; + +void +Options::parse_args (int argc, char *argv[]) +{ + ACE_LOG_MSG->open (argv[0]); + + ACE_Get_Opt getopt (argc, argv, "C:c:bdH:i:L:l:M:nS:s:t:T:v"); + int c; + + while ((c = getopt ()) != -1) + switch (c) + { + case 'b': + this->t_flags (THR_BOUND); + break; + case 'C': + this->consumer_file (getopt.optarg); + break; + case 'c': + this->consumer_port (getopt.optarg); + break; + case 'd': + this->debugging_ = 1; + break; + case 'H': + this->high_water_mark (ACE_OS::atoi (getopt.optarg)); + break; + case 'i': + this->iterations (ACE_OS::atoi (getopt.optarg)); + break; + case 'L': + this->low_water_mark (ACE_OS::atoi (getopt.optarg)); + break; + case 'l': + this->initial_queue_length (ACE_OS::atoi (getopt.optarg)); + break; + case 'M': + this->message_size (ACE_OS::atoi (getopt.optarg)); + break; + case 'n': + this->t_flags (THR_NEW_LWP); + break; + case 'S': + this->supplier_file (getopt.optarg); + break; + case 's': + this->supplier_port (getopt.optarg); + break; + case 'T': + if (ACE_OS::strcasecmp (getopt.optarg, "ON") == 0) + ACE_Trace::start_tracing (); + else if (ACE_OS::strcasecmp (getopt.optarg, "OFF") == 0) + ACE_Trace::stop_tracing (); + break; + case 't': + this->thr_count (ACE_OS::atoi (getopt.optarg)); + break; + case 'v': + this->verbosity_ = 1; + break; + default: + ::fprintf (stderr, "%s\n" + "\t[-b] (THR_BOUND)\n" + "\t[-C consumer file]\n" + "\t[-c consumer port]\n" + "\t[-d] (enable debugging)\n" + "\t[-H high water mark]\n" + "\t[-i number of test iterations]\n" + "\t[-L low water mark]\n" + "\t[-M] message size \n" + "\t[-n] (THR_NEW_LWP)\n" + "\t[-q max queue size]\n" + "\t[-S supplier file]\n" + "\t[-s supplier port]\n" + "\t[-t number of threads]\n" + "\t[-v] (verbose) \n", + argv[0]); + ::exit (1); + /* NOTREACHED */ + break; + } + + if (this->verbose ()) + ACE_OS::printf ("%8d = initial concurrency hint\n" + "%8d = total iterations\n" + "%8d = thread count\n" + "%8d = low water mark\n" + "%8d = high water mark\n" + "%8d = message_size\n" + "%8d = initial queue length\n" + "%8d = THR_BOUND\n" + "%8d = THR_NEW_LWP\n", + ACE_OS::thr_getconcurrency (), + this->iterations (), + this->thr_count (), + this->low_water_mark (), + this->high_water_mark (), + this->message_size (), + this->initial_queue_length (), + (this->t_flags () & THR_BOUND) != 0, + (this->t_flags () & THR_NEW_LWP) != 0); +} + +#endif /* ACE_HAS_THREADS */ diff --git a/examples/ASX/UPIPE_Event_Server/Options.h b/examples/ASX/UPIPE_Event_Server/Options.h new file mode 100644 index 00000000000..bd73eae2bae --- /dev/null +++ b/examples/ASX/UPIPE_Event_Server/Options.h @@ -0,0 +1,83 @@ +/* -*- C++ -*- */ +// @(#)Options.h 1.1 10/18/96 + +// Option manager for Event Server. + +#if !defined (DEVICE_OPTIONS_H) +#define DEVICE_OPTIONS_H + +#include "ace/OS.h" +#include "ace/Profile_Timer.h" + +#if defined (ACE_HAS_THREADS) + +class Options +{ +public: + Options (void); + ~Options (void); + void parse_args (int argc, char *argv[]); + + void stop_timer (void); + void start_timer (void); + + void thr_count (size_t count); + size_t thr_count (void); + + void initial_queue_length (size_t length); + size_t initial_queue_length (void); + + void high_water_mark (size_t size); + size_t high_water_mark (void); + + void low_water_mark (size_t size); + size_t low_water_mark (void); + + void message_size (size_t size); + size_t message_size (void); + + void iterations (size_t n); + size_t iterations (void); + + void t_flags (long flag); + long t_flags (void); + + void supplier_port (char *port); + char *supplier_port (void); + + void consumer_port (char *port); + char *consumer_port (void); + + void supplier_file (char *file); + char *supplier_file (void); + + void consumer_file (char *file); + char *consumer_file (void); + + int debug (void); + int verbose (void); + + void print_results (void); + +private: + ACE_Profile_Timer itimer_; // Time the process. + size_t thr_count_; // Number of threads to spawn. + long t_flags_; // Flags to thr_create(). + size_t high_water_mark_; // ACE_Task high water mark. + size_t low_water_mark_; // ACE_Task low water mark. + size_t message_size_; // Size of a message. + size_t initial_queue_length_; // Initial number of items in the queue. + size_t iterations_; // Number of iterations to run the test program. + int debugging_; // Extra debugging info. + int verbosity_; // Extra verbose messages. + char *consumer_port_; // Port that the Consumer_Router is using. + char *supplier_port_; // Port that the Supplier_Router is using. + char *consumer_file_; // file that the Consumer_Router is using. + char *supplier_file_; // file that the Supplier_Router is using. +}; + +extern Options options; + +#include "Options.i" +#endif /* ACE_HAS_THREADS */ +#endif /* DEVICE_OPTIONS_H */ diff --git a/examples/ASX/UPIPE_Event_Server/Options.i b/examples/ASX/UPIPE_Event_Server/Options.i new file mode 100644 index 00000000000..226e46b1548 --- /dev/null +++ b/examples/ASX/UPIPE_Event_Server/Options.i @@ -0,0 +1,161 @@ +/* -*- C++ -*- */ +// @(#)Options.i 1.1 10/18/96 + +// Option manager for ustreams. + +inline void +Options::supplier_port (char *port) +{ + this->supplier_port_ = port; +} + +inline char * +Options::supplier_port (void) +{ + return this->supplier_port_; +} + +inline void +Options::supplier_file (char *file) +{ + this->supplier_file_ = file; +} + +inline char * +Options::supplier_file (void) +{ + return this->supplier_file_; +} + +inline void +Options::consumer_file (char *file) +{ + this->consumer_file_ = file; +} + +inline char * +Options::consumer_file (void) +{ + return this->consumer_file_; +} + +inline void +Options::consumer_port (char *port) +{ + this->consumer_port_ = port; +} + +inline char * +Options::consumer_port (void) +{ + return this->consumer_port_; +} + +inline void +Options::start_timer (void) +{ + this->itimer_.start (); +} + +inline void +Options::stop_timer (void) +{ + this->itimer_.stop (); +} + +inline void +Options::thr_count (size_t count) +{ + this->thr_count_ = count; +} + +inline size_t +Options::thr_count (void) +{ + return this->thr_count_; +} + +inline void +Options::initial_queue_length (size_t length) +{ + this->initial_queue_length_ = length; +} + +inline size_t +Options::initial_queue_length (void) +{ + return this->initial_queue_length_; +} + +inline void +Options::high_water_mark (size_t size) +{ + this->high_water_mark_ = size; +} + +inline size_t +Options::high_water_mark (void) +{ + return this->high_water_mark_; +} + +inline void +Options::low_water_mark (size_t size) +{ + this->low_water_mark_ = size; +} + +inline size_t +Options::low_water_mark (void) +{ + return this->low_water_mark_; +} + +inline void +Options::message_size (size_t size) +{ + this->message_size_ = size; +} + +inline size_t +Options::message_size (void) +{ + return this->message_size_; +} + +inline void +Options::iterations (size_t n) +{ + this->iterations_ = n; +} + +inline size_t +Options::iterations (void) +{ + return this->iterations_; +} + +inline void +Options::t_flags (long flag) +{ + this->t_flags_ |= flag; +} + +inline long +Options::t_flags (void) +{ + return this->t_flags_; +} + +inline int +Options::debug (void) +{ + return this->debugging_; +} + +inline int +Options::verbose (void) +{ + return this->verbosity_; +} + diff --git a/examples/ASX/UPIPE_Event_Server/Peer_Router.cpp b/examples/ASX/UPIPE_Event_Server/Peer_Router.cpp new file mode 100644 index 00000000000..6aba899f4ea --- /dev/null +++ b/examples/ASX/UPIPE_Event_Server/Peer_Router.cpp @@ -0,0 +1,273 @@ +#if !defined (_PEER_ROUTER_C) +// @(#)Peer_Router.cpp 1.1 10/18/96 + +#define _PEER_ROUTER_C + +#include "ace/Get_Opt.h" +#include "ace/Service_Config.h" +#include "ace/Log_Msg.h" +#include "Peer_Router.h" +#include "Options.h" + +#if defined (ACE_HAS_THREADS) + +// Define some short-hand macros to deal with long templates +// names... + +#define PH PEER_HANDLER +#define PA PEER_ACCEPTOR +#define PAD PEER_ADDR +#define PK PEER_KEY +#define PM PEER_MAP + +template <class PH, class PK> int +Acceptor_Factory<PH, PK>::init (int argc, char *argv[]) +{ + ACE_Get_Opt get_opt (argc, argv, "df:", 0); + ACE_UPIPE_Addr addr; + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'f': + addr.set (get_opt.optarg); + break; + case 'd': + break; + default: + break; + } + + if (this->open (addr, ACE_Service_Config::reactor ()) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); + return 0; +} + +template <class PH, class PK> +Acceptor_Factory<PH, PK>::Acceptor_Factory (Peer_Router<PH, PK> *pr) + : pr_ (pr) +{ +} + +template <class PH, class PK> Peer_Router<PH, PK> * +Acceptor_Factory<PH, PK>::router (void) +{ + return this->pr_; +} + +template <class ROUTER, class KEY> +Peer_Handler<ROUTER, KEY>::Peer_Handler (ACE_Thread_Manager *tm) + : ACE_Svc_Handler<ACE_UPIPE_Stream, ACE_UPIPE_Addr, ACE_MT_SYNCH> (tm) +{ +} + +template <class ROUTER, class KEY> int +Peer_Handler<ROUTER, KEY>::svc (void) +{ + ACE_Thread_Control thread_control (tm); + // just a try !! + // we're just reading from our ACE_Message_Queue + ACE_Message_Block *db, *hb; + int n; + // do an endless loop + for (;;) + { + db = new ACE_Message_Block (BUFSIZ); + hb = new ACE_Message_Block (sizeof (KEY), ACE_Message_Block::MB_PROTO, db); + + if ((n = this->peer ().recv (db->rd_ptr (), db->size ())) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p", "recv failed"), -1); + else if (n == 0) // Client has closed down the connection. + { + + if (this->router_task_->unbind_peer (this->get_handle ()) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p", "unbind failed"), -1); + ACE_DEBUG ((LM_DEBUG, "(%t) shutting down \n")); + return -1; // We do not need to be deregistered by reactor + // as we were not registered at all + } + else // Transform incoming buffer into a Message and pass downstream. + { + db->wr_ptr (n); + *(long *) hb->rd_ptr () = this->get_handle (); // structure assignment. + hb->wr_ptr (sizeof (long)); + if (this->router_task_->reply (hb) == -1) + { + cout << "Peer_Handler.svc : router_task->reply failed" << endl ; + return -1; + } + + // return this->router_task_->reply (hb) == -1 ? -1 : 0; + } + } + return 0; +} + +template <class ROUTER, class KEY> int +Peer_Handler<ROUTER, KEY>::put (ACE_Message_Block *mb, ACE_Time_Value *) +{ + return this->peer ().send_n (mb->rd_ptr (), mb->length ()); +} + +// Create a new handler and point its ROUTER_TASK_ data member to the +// corresponding router. Note that this router is extracted out of +// the Acceptor_Factory * that is passed in via the +// ACE_Acceptor::handle_input() method. + +template <class ROUTER, class KEY> int +Peer_Handler<ROUTER, KEY>::open (void *a) +{ + char buf[BUFSIZ], *p = buf; + + if (this->router_task_->info (&p, sizeof buf) != -1) + ACE_DEBUG ((LM_DEBUG, "(%t) creating handler for %s, fd = %d, this = %d\n", + buf, this->get_handle (), a)); + else + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "info"), -1); + + if ( this->activate (options.t_flags ()) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "activation of thread failed"), -1); + else if (this->router_task_->bind_peer (this->get_handle (), this) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "bind_peer"), -1); + return 0; +} + +// Receive a message from a supplier.. + +template <class ROUTER, class KEY> int +Peer_Handler<ROUTER, KEY>::handle_input (ACE_HANDLE h) +{ + + ACE_DEBUG ((LM_DEBUG, "(%t) input arrived on sd %d\n", h)); +// ACE_Service_Config::reactor ()->remove_handler(h, +// ACE_Event_Handler::RWE_MASK +// |ACE_Event_Handler::DONT_CALL); +// this method should be called only if the peer shuts down +// so we deactivate our ACE_Message_Queue to awake our svc thread + + return 0; + +#if 0 + ACE_Message_Block *db = new ACE_Message_Block (BUFSIZ); + ACE_Message_Block *hb = new ACE_Message_Block (sizeof (KEY), ACE_Message_Block::MB_PROTO, db); + int n; + + if ((n = this->peer ().recv (db->rd_ptr (), db->size ())) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p", "recv failed"), -1); + else if (n == 0) // Client has closed down the connection. + { + if (this->router_task_->unbind_peer (this->get_handle ()) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p", "unbind failed"), -1); + ACE_DEBUG ((LM_DEBUG, "(%t) shutting down %d\n", h)); + return -1; // Instruct the ACE_Reactor to deregister us by returning -1. + } + else // Transform incoming buffer into a Message and pass downstream. + { + db->wr_ptr (n); + *(long *) hb->rd_ptr () = this->get_handle (); // structure assignment. + hb->wr_ptr (sizeof (long)); + return this->router_task_->reply (hb) == -1 ? -1 : 0; + } +#endif +} + +template <class PH, class PK> +Peer_Router<PH, PK>::Peer_Router (ACE_Thread_Manager *tm) + : ACE_Task<ACE_MT_SYNCH> (tm) +{ +} + +template <class PH, class PK> int +Peer_Router<PH, PK>::send_peers (ACE_Message_Block *mb) +{ + ACE_Map_Iterator<PK, PH *, ACE_RW_Mutex> map_iter = this->peer_map_; + int bytes = 0; + int iterations = 0; + ACE_Message_Block *data_block = mb->cont (); + for (ACE_Map_Entry<PK, PH *> *ss = 0; + map_iter.next (ss) != 0; + map_iter.advance ()) + { + if (options.debug ()) + ACE_DEBUG ((LM_DEBUG, "(%t) sending to peer via sd %d\n", ss->ext_id_)); + + iterations++; + bytes += ss->int_id_->put (data_block); + } + + delete mb; + return bytes == 0 ? 0 : bytes / iterations; +} + +template <class PH, class PK> +Peer_Router<PH, PK>::~Peer_Router (void) +{ +} + +template <class PH, class PK> ACE_INLINE int +Peer_Router<PH, PK>::fini (void) +{ + delete this->acceptor_; + return 0; +} + +template <class PH, class PK> ACE_INLINE int +Peer_Router<PH, PK>::control (ACE_Message_Block *mb) +{ + ACE_IO_Cntl_Msg *ioc = (ACE_IO_Cntl_Msg *) mb->rd_ptr (); + ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds command; + + switch (command = ioc->cmd ()) + { + case ACE_IO_Cntl_Msg::SET_LWM: + case ACE_IO_Cntl_Msg::SET_HWM: + this->water_marks (command, *(size_t *) mb->cont ()->rd_ptr ()); + break; + default: + return -1; + } + return 0; +} + +template <class PH, class PK> ACE_INLINE int +Peer_Router<PH, PK>::unbind_peer (PK key) +{ + return this->peer_map_.unbind (key); +} + +template <class PH, class PK> ACE_INLINE int +Peer_Router<PH, PK>::bind_peer (PK key, Peer_Handler<Peer_Router<PH, PK>, PK> *ph) +{ + PH *peer_handler = (PH *) ph; + return this->peer_map_.bind (key, peer_handler); +} + +template <class PH, class PK> ACE_INLINE int +Peer_Router<PH, PK>::init (int argc, char *argv[]) +{ + this->acceptor_ = new Acceptor_Factory <PH, PK> (this); + + if (this->acceptor_->init (argc, argv) == -1 + || this->peer_map_.open () == -1) + return -1; + else + { + ACE_UPIPE_Addr addr; + ACE_UPIPE_Acceptor &pa = this->acceptor_->acceptor (); + + if (pa.get_local_addr (addr) != -1) + ACE_DEBUG ((LM_DEBUG, "(%t) initializing %s, file = %s, fd = %d, this = %u\n", + this->name (), addr.get_path_name (), pa.get_handle (), this)); + else + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "get_local_addr"), -1); + } + return 0; +} + +#undef PH +#undef PA +#undef PAD +#undef PK +#undef PM +#endif /* ACE_HAS_THREADS */ +#endif /* _PEER_ROUTER_C */ diff --git a/examples/ASX/UPIPE_Event_Server/Peer_Router.h b/examples/ASX/UPIPE_Event_Server/Peer_Router.h new file mode 100644 index 00000000000..b344497d4b1 --- /dev/null +++ b/examples/ASX/UPIPE_Event_Server/Peer_Router.h @@ -0,0 +1,116 @@ +/* -*- C++ -*- */ +// @(#)Peer_Router.h 1.1 10/18/96 + +// The interface between one or more peers and a stream. A peer +// typically runs remotely on another machine. + +#if !defined (_PEER_ROUTER_H) +#define _PEER_ROUTER_H + +#include "ace/Acceptor.h" +#include "ace/Svc_Handler.h" +#include "ace/UPIPE_Acceptor.h" +#include "ace/UPIPE_Addr.h" +#include "ace/Thread_Manager.h" +#include "ace/Map_Manager.h" + +#if defined (ACE_HAS_THREADS) + +// Forward declaration. +template <class PEER_HANDLER, class KEY> +class Peer_Router; + +template <class PEER_HANDLER, class KEY> +class Acceptor_Factory : public ACE_Acceptor<PEER_HANDLER, ACE_UPIPE_ACCEPTOR> +{ +public: + Acceptor_Factory (Peer_Router<PEER_HANDLER, KEY> *pr); + Peer_Router<PEER_HANDLER, KEY> *router (void); + + int init (int argc, char *argv[]); + // Initialize the acceptor when it's linked dynamically. + +private: + Peer_Router<PEER_HANDLER, KEY> *pr_; +}; + +// Receive input from a Peer.. +template <class ROUTER, class KEY> +class Peer_Handler : public ACE_Svc_Handler<ACE_UPIPE_STREAM, ACE_MT_SYNCH> +{ +public: + Peer_Handler (ACE_Thread_Manager * = 0); + + virtual int open (void * = 0); + // Called by the ACE_Acceptor::handle_input() to activate this object. + + virtual int handle_input (ACE_HANDLE); + // Receive input from the peer.. + + virtual int put (ACE_Message_Block *, ACE_Time_Value *tv = 0); + // Send output to a peer. + +protected: + ROUTER *router_task_; + // Pointer to write task.. + +private: + // Don't need this method here... + virtual int svc (void); +}; + +// This abstract base class provides mechanisms for routing messages +// to/from a ACE_Stream from/to one or more peers (which are typically +// running on remote hosts). A subclass of Peer_Router overrides the +// open(), close(), and put() methods in order to specialize the +// behavior of the router to meet application-specific requirements. + +template <class PEER_HANDLER, class PEER_KEY> +class Peer_Router : public ACE_Task<ACE_MT_SYNCH> +{ +public: + Peer_Router (ACE_Thread_Manager * = 0); + ~Peer_Router (void); + + typedef Peer_Handler<Peer_Router<PEER_HANDLER, PEER_KEY>, PEER_KEY> HANDLER; + + // Remove a PEER_HANDLER from the PEER_MAP. + virtual int unbind_peer (PEER_KEY); + + // Add a PEER_HANDLER to the PEER_MAP. + virtual int bind_peer (PEER_KEY, HANDLER *); + + // Send the message block to the peer(s).. + int send_peers (ACE_Message_Block *mb); + +protected: +// Handle control messages arriving from adjacent Modules. + virtual int control (ACE_Message_Block *); + + // Map used to keep track of active peers. + ACE_Map_Manager <PEER_KEY, PEER_HANDLER *, ACE_RW_Mutex> peer_map_; + + // Dynamic linking initialization hooks inherited from ACE_Task. + virtual int init (int argc, char *argv[]); + virtual int fini (void); + + // Factory for accepting new PEER_HANDLERs. + Acceptor_Factory<PEER_HANDLER, PEER_KEY> *acceptor_; + +private: +// Prevent copies and pass-by-value. + Peer_Router (const Peer_Router<PEER_HANDLER, PEER_KEY> &); + void operator= (const Peer_Router<PEER_HANDLER, PEER_KEY> &); +}; + +#if defined (__ACE_INLINE__) +#define ACE_INLINE inline +#else +#define ACE_INLINE +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Peer_Router.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ +#endif /* ACE_HAS_THREADS */ +#endif /* _PEER_ROUTER_H */ diff --git a/examples/ASX/UPIPE_Event_Server/Supplier_Router.cpp b/examples/ASX/UPIPE_Event_Server/Supplier_Router.cpp new file mode 100644 index 00000000000..414fc5c9ccf --- /dev/null +++ b/examples/ASX/UPIPE_Event_Server/Supplier_Router.cpp @@ -0,0 +1,126 @@ +#include "Supplier_Router.h" +// @(#)Supplier_Router.cpp 1.1 10/18/96 + +#include "Options.h" + +#if defined (ACE_HAS_THREADS) + +typedef Acceptor_Factory<Supplier_Handler, SUPPLIER_KEY> SUPPLIER_FACTORY; + +int +Supplier_Handler::open (void *a) +{ + SUPPLIER_FACTORY *af = (SUPPLIER_FACTORY *) a; + this->router_task_ = af->router (); + return this->Peer_Handler<SUPPLIER_ROUTER, SUPPLIER_KEY>::open (a); +} + +Supplier_Handler::Supplier_Handler (ACE_Thread_Manager *tm) + : Peer_Handler<SUPPLIER_ROUTER, SUPPLIER_KEY> (tm) +{ +} + +// Create a new router and associate it with the REACTOR parameter.. + +Supplier_Router::Supplier_Router (ACE_Thread_Manager *tm) + : SUPPLIER_ROUTER (tm) +{ +} + +// Handle incoming messages in a separate thread.. + +int +Supplier_Router::svc (void) +{ + ACE_ASSERT (this->is_writer ()); + + ACE_Thread_Control tc (this->thr_mgr ()); + ACE_Message_Block *message_block = 0; + + if (options.debug ()) + ACE_DEBUG ((LM_DEBUG, "(%t) starting svc in %s\n", this->name ())); + + while (this->getq (message_block) > 0) + { + if (this->put_next (message_block) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "(%t) put_next failed in %s\n", this->name ()), -1); + } + + return 0; + // Note the implicit ACE_OS::thr_exit() via ACE_Thread_Control's destructor. +} + +// Initialize the Router.. + +int +Supplier_Router::open (void *) +{ + ACE_ASSERT (this->is_writer ()); + + char *argv[3]; + + argv[0] = (char *) this->name (); + argv[1] = options.supplier_file (); + argv[2] = 0; + + if (this->init (1, &argv[1]) == -1) + return -1; + // Make this an active object. Return this->activate + // (options.t_flags ()); +} + +// Close down the router.. + +int +Supplier_Router::close (u_long) +{ + ACE_ASSERT (this->is_writer ()); + this->peer_map_.close (); + this->msg_queue ()->deactivate(); + return 0; +} + +// Send a MESSAGE_BLOCK to the supplier(s).. + +int +Supplier_Router::put (ACE_Message_Block *mb, ACE_Time_Value *) +{ + ACE_ASSERT (this->is_writer ()); + + if (mb->msg_type () == ACE_Message_Block::MB_IOCTL) + { + this->control (mb); + return this->put_next (mb); + } + else + { +//printf("supplier-Router is routing: send_peers\n"); + return this->send_peers (mb); + } +} + +// Return information about the Supplier_Router ACE_Module.. + +int +Supplier_Router::info (char **strp, size_t length) const +{ + char buf[BUFSIZ]; + ACE_UPIPE_Addr addr; + const char *mod_name = this->name (); + ACE_UPIPE_Acceptor &sa = (ACE_UPIPE_Acceptor &) *this->acceptor_; + + if (sa.get_local_addr (addr) == -1) + return -1; + + ACE_OS::sprintf (buf, "%s\t %s/ %s", + mod_name, "upipe", + "# supplier router\n"); + + if (*strp == 0 && (*strp = ACE_OS::strdup (mod_name)) == 0) + return -1; + else + ACE_OS::strncpy (*strp, mod_name, length); + return ACE_OS::strlen (mod_name); +} + +#endif /* ACE_HAS_THREADS */ diff --git a/examples/ASX/UPIPE_Event_Server/Supplier_Router.h b/examples/ASX/UPIPE_Event_Server/Supplier_Router.h new file mode 100644 index 00000000000..bb304042586 --- /dev/null +++ b/examples/ASX/UPIPE_Event_Server/Supplier_Router.h @@ -0,0 +1,52 @@ +/* -*- C++ -*- */ +// @(#)Supplier_Router.h 1.1 10/18/96 + +// The interface between a supplier and an Event Service ACE_Stream. + +#if !defined (_SUPPLIER_ROUTER_H) +#define _SUPPLIER_ROUTER_H + +#include "ace/UPIPE_Addr.h" +#include "ace/UPIPE_Acceptor.h" +#include "ace/Map_Manager.h" +#include "ace/Svc_Handler.h" +#include "Peer_Router.h" + +#if defined (ACE_HAS_THREADS) + +// Forward declaration. +class Supplier_Handler; + +// Type of search key for SUPPLIER_MAP. +typedef long SUPPLIER_KEY; + +// Instantiated type for routing messages to suppliers. + +typedef Peer_Router<Supplier_Handler, SUPPLIER_KEY> SUPPLIER_ROUTER; + +class Supplier_Handler + : public Peer_Handler<SUPPLIER_ROUTER, SUPPLIER_KEY> +{ +public: + Supplier_Handler (ACE_Thread_Manager *tm = 0); + virtual int open (void *); +}; + +class Supplier_Router : public SUPPLIER_ROUTER +{ +public: + Supplier_Router (ACE_Thread_Manager *); + +protected: + // ACE_Task hooks.. + virtual int open (void *a = 0); + virtual int close (u_long flags = 0); + virtual int put (ACE_Message_Block *msg, ACE_Time_Value * = 0); + virtual int svc (void); + + // Dynamic linking hooks inherited from Peer_Router. + virtual int info (char **info_string, size_t length) const; +}; + +#endif /* ACE_HAS_THREADS */ +#endif /* _SUPPLIER_ROUTER_H */ diff --git a/examples/ASX/UPIPE_Event_Server/event_server.cpp b/examples/ASX/UPIPE_Event_Server/event_server.cpp new file mode 100644 index 00000000000..bdafdb23de7 --- /dev/null +++ b/examples/ASX/UPIPE_Event_Server/event_server.cpp @@ -0,0 +1,252 @@ +// Test the event server. +// @(#)event_server.cpp 1.1 10/18/96 + +#include "ace/Log_Msg.h" +#include "ace/Stream.h" +#include "ace/Service_Config.h" +#include "Options.h" +#include "Consumer_Router.h" +#include "Event_Analyzer.h" +#include "Supplier_Router.h" +#include "ace/UPIPE_Acceptor.h" +#include "ace/UPIPE_Connector.h" + +#if defined (ACE_HAS_THREADS) + +typedef ACE_Stream<ACE_MT_SYNCH> MT_Stream; +typedef ACE_Module<ACE_MT_SYNCH> MT_Module; + +// Handle SIGINT and terminate the entire application. + +class Quit_Handler : public ACE_Sig_Adapter +{ +public: + Quit_Handler (void); + virtual int handle_input (ACE_HANDLE fd); +}; + +Quit_Handler::Quit_Handler (void) + : ACE_Sig_Adapter (ACE_Sig_Handler_Ex (ACE_Service_Config::end_reactor_event_loop)) +{ + // Register to trap input from the user. + 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")); + // Register to trap the SIGINT signal. + else if (ACE_Service_Config::reactor ()->register_handler + (SIGINT, this) == -1) + ACE_ERROR ((LM_ERROR, "%p\n", "register_handler")); +} + +int +Quit_Handler::handle_input (ACE_HANDLE) +{ + options.stop_timer (); + ACE_DEBUG ((LM_INFO, " (%t) closing down the test\n")); + options.print_results (); + + ACE_Service_Config::end_reactor_event_loop (); + return 0; +} + +static void * +consumer (void *) +{ + ACE_UPIPE_Stream c_stream; + ACE_UPIPE_Addr c_addr ("/tmp/conupipe"); + + int iter = options.iterations (); + int verb = options.verbose (); + int msiz = options.message_size (); + int secs, par1, par2, i; + time_t currsec; + + if (verb) + cout << "consumer starting connect" << endl; + + ACE_UPIPE_Connector con; + + if (con.connect (c_stream, c_addr) == -1) + ACE_DEBUG ((LM_INFO, " (%t) connect failed\n")); + else + cout << "consumer :we're connected" << endl; + + char buf[BUFSIZ]; + int n; + ACE_Message_Block *mb_p; + + int done = 0; + int cnt = 0; + ACE_OS::time (&currsec); + + par1= (time_t) currsec; + + while (done == 0 + && ((n = c_stream.recv (mb_p)) != -1)) + if (mb_p->length () > 1) + { + cnt++; + if (verb) + cout << " consumer received message !!!!!! " + << mb_p->rd_ptr () << endl; + } + else + { + if (verb) + cout << "consumer got last mb" + << (char) * (mb_p->rd_ptr ()) << endl; + c_stream.close (); + done = 1; + } + + ACE_OS::time (&currsec); + par2 = (time_t) currsec; + + secs = par2 - par1; + + if (secs <= 0) + secs=1; + + cout << "consumer got " << cnt << " messages of size " << msiz + << "within " << secs << " seconds" << endl; + + ACE_OS::sleep (2); + cout << "consumer terminating " << endl; + return 0; +} + +static void * +supplier (void *dummy) +{ + ACE_UPIPE_Stream s_stream; + ACE_UPIPE_Addr serv_addr ("/tmp/supupipe"); + ACE_UPIPE_Connector con; + + int iter = options.iterations (); + int verb = options.verbose (); + int msiz = options.message_size (); + cout << "supplier starting connect" << endl; + + if (con.connect (s_stream, serv_addr) == -1) + ACE_DEBUG ((LM_INFO, " (%t) connect failed\n")); + + cout << "supplier : we're connected" << endl; + int n; + n = 0; + ACE_Message_Block * mb_p; + + while (n < iter) + { + mb_p = new ACE_Message_Block (msiz); + strcpy (mb_p->rd_ptr (), (char *) dummy); + mb_p->length (msiz); + if (verb) + cout << "supplier sending 1 message_block" << endl; + if (s_stream.send (mb_p) == -1) + { + cout << "supplier send failed" << endl; + return (void *) -1; + } + n++; + } + + mb_p = new ACE_Message_Block (10); + mb_p->length (1); + *mb_p->rd_ptr () = 'g'; + + cout << "supplier sending last message_block" << endl; + + if (s_stream.send (mb_p) == -1) + { + cout << "supplier send last mb failed" << endl; + return (void *) -1; + } + mb_p = new ACE_Message_Block (10); + mb_p->length (0); + + if (verb) + cout << "supplier sending very last message_block" << endl; + + if (s_stream.send (mb_p) == -1) + { + cout << "supplier send very last mb failed" << endl; + return (void *) -1; + } + + ACE_OS::sleep (2); + cout << "supplier terminating" << endl; + return 0; +} + +int +main (int argc, char *argv[]) +{ + ACE_Service_Config daemon; + + options.parse_args (argc, argv); + options.start_timer (); + + // Primary ACE_Stream for EVENT_SERVER application. + MT_Stream event_server; + + // Enable graceful shutdowns.... + Quit_Handler quit_handler; + + // Create the modules.. + + MT_Module *sr = new MT_Module ("Supplier_Router", + new Supplier_Router (ACE_Service_Config::thr_mgr ())); + MT_Module *ea = new MT_Module ("Event_Analyzer", + new Event_Analyzer, + new Event_Analyzer); + MT_Module *cr = new MT_Module ("Consumer_Router", + 0, // 0 triggers the creation of a ACE_Thru_Task... + new Consumer_Router (ACE_Service_Config::thr_mgr ())); + + // Push the modules onto the event_server stream. + + if (event_server.push (sr) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "push (Supplier_Router)"), -1); + + if (event_server.push (ea) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "push (Event_Analyzer)"), -1); + + if (event_server.push (cr) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "push (Consumer_Router)"), -1); + + // Set the high and low water marks appropriately. + + int wm = options.low_water_mark (); + + if (event_server.control (ACE_IO_Cntl_Msg::SET_LWM, &wm) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "push (setting low watermark)"), -1); + + wm = options.high_water_mark (); + if (event_server.control (ACE_IO_Cntl_Msg::SET_HWM, &wm) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "push (setting high watermark)"), -1); + + // spawn the two threads. + + if (ACE_Service_Config::thr_mgr ()->spawn (ACE_THR_FUNC (consumer), (void *) 0, + THR_NEW_LWP | THR_DETACHED) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), 1); + + else if (ACE_Service_Config::thr_mgr ()->spawn (ACE_THR_FUNC (supplier), (void *) "hello", + THR_NEW_LWP | THR_DETACHED) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), 1); + + // Perform the main event loop waiting for the user to type ^C or to + // enter a line on the ACE_STDIN. + + daemon.run_reactor_event_loop (); + + ACE_DEBUG ((LM_DEBUG, "main exiting\n")); +} +#else +int +main (void) +{ + ACE_ERROR_RETURN ((LM_ERROR, "test not defined for this platform\n"), -1); +} +#endif /* ACE_HAS_THREADS */ diff --git a/examples/CORBA/Makefile b/examples/CORBA/Makefile new file mode 100644 index 00000000000..5ca20af9257 --- /dev/null +++ b/examples/CORBA/Makefile @@ -0,0 +1,65 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the ACE_MT_CORBA_Handler tests +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +SRC = Test_i.cpp client.cpp server.cpp + +SVR_OBJS = TestS.o Test_i.o server.o +CLT_OBJS = TestC.o client.o + +LDLIBS = + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.lib.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Orbix related macros and target settings. +#---------------------------------------------------------------------------- + +ORBIX_BINDIR = $(ORBIX_ROOT)/bin +ORBIX_LIBDIR = $(ORBIX_ROOT)/lib +ORBIX_INCDIR = $(ORBIX_ROOT)/include + +CPPFLAGS += -DEXCEPTIONS -I$(ORBIX_INCDIR) -DWANT_ORBIX_FDS +LDFLAGS += -L$(ORBIX_LIBDIR) -R $(ORBIX_LIBDIR) + +IDLFLAGS = -s S.cpp -c C.cpp -B + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +all: client server + +client: $(addprefix $(VDIR),$(CLT_OBJS)) + $(LINK.cc) -o client $(addprefix $(VDIR),$(CLT_OBJS)) $(LDFLAGS) -lITsrvmt $(VLDLIBS) + +server: $(addprefix $(VDIR),$(SVR_OBJS)) + $(LINK.cc) -o server $(addprefix $(VDIR),$(SVR_OBJS)) $(LDFLAGS) -lITsrvmt $(VLDLIBS) + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + + + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/CORBA/Test.idl b/examples/CORBA/Test.idl new file mode 100644 index 00000000000..33e8adce847 --- /dev/null +++ b/examples/CORBA/Test.idl @@ -0,0 +1,6 @@ +interface Test +// @(#)Test.idl 1.1 10/18/96 + +{ + void method (in long input1); +}; diff --git a/examples/CORBA/Test_i.cpp b/examples/CORBA/Test_i.cpp new file mode 100644 index 00000000000..2f7c4301470 --- /dev/null +++ b/examples/CORBA/Test_i.cpp @@ -0,0 +1,10 @@ +#include "Test_i.h" +// @(#)Test_i.cpp 1.1 10/18/96 + + +void +Test_i::method (long input, + ACE_CORBA_1 (Environment) &) +{ + ACE_DEBUG ((LM_DEBUG, "received a number %d\n", input)); +} diff --git a/examples/CORBA/Test_i.h b/examples/CORBA/Test_i.h new file mode 100644 index 00000000000..1e8b8c471bd --- /dev/null +++ b/examples/CORBA/Test_i.h @@ -0,0 +1,14 @@ +/* -*- C++ -*- */ +// @(#)Test_i.h 1.1 10/18/96 + +#include "ace/Log_Msg.h" +#include "Test.hh" + +class Test_i +{ +public: + virtual void method (long input, + ACE_CORBA_1 (Environment) &IT_env = ACE_CORBA_1 (default_environment)); +}; + +DEF_TIE_Test (Test_i) diff --git a/examples/CORBA/client.cpp b/examples/CORBA/client.cpp new file mode 100644 index 00000000000..8538bcc2eda --- /dev/null +++ b/examples/CORBA/client.cpp @@ -0,0 +1,26 @@ +#include "ace/Log_Msg.h" +// @(#)client.cpp 1.1 10/18/96 + +#include "Test.hh" + +int +main (int argc, char *argv[]) +{ + char *host = argc == 2 ? argv[1] : ACE_DEFAULT_SERVER_HOST; + + Test_var my_test; + + TRY { + my_test = Test::_bind ("", host, IT_X); + my_test->method (5); + } CATCHANY { + cerr << IT_X << endl; + return -1; + } ENDTRY; + + ACE_DEBUG ((LM_DEBUG, "everything works!\n")); + + // Memory for my_test is automatically released by destructor of + // smart pointer. + return 0; +} diff --git a/examples/CORBA/server.cpp b/examples/CORBA/server.cpp new file mode 100644 index 00000000000..89cccefcee8 --- /dev/null +++ b/examples/CORBA/server.cpp @@ -0,0 +1,37 @@ +#include "ace/Service_Config.h" +// @(#)server.cpp 1.1 10/18/96 + +#include "ace/CORBA_Handler.h" +#include "Test_i.h" + +#if defined (ACE_HAS_ORBIX) + +#if defined (ACE_HAS_MT_ORBIX) +typedef ACE_MT_CORBA_Handler CORBA_HANDLER; +#else +typedef ACE_ST_CORBA_Handler CORBA_HANDLER; +#endif /* ACE_HAS_MT_ORBIX */ + +int +main (int argc, char *argv[]) +{ + ACE_Service_Config daemon; + + char pwd[BUFSIZ]; + char app[BUFSIZ]; + + ACE_OS::getcwd (pwd, sizeof pwd); + ACE_OS::sprintf (app, "%s/%s", pwd, argv[0]); + + if (CORBA_HANDLER::instance ()->activate_service (Test_IMPL, 0, app) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "Could not activate services for supplier\n"), -1); + + TIE_Test (Test_i) test (new Test_i); + + for (;;) + if (CORBA_HANDLER::instance ()->reactor ()->handle_events () == -1) + break; + + return 0; +} +#endif /* ACE_HAS_ORBIX */ diff --git a/examples/Connection/Makefile b/examples/Connection/Makefile new file mode 100644 index 00000000000..96c53892d51 --- /dev/null +++ b/examples/Connection/Makefile @@ -0,0 +1,26 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the Connection tests +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +INFO = README + +DIRS = blocking \ + misc \ + non_blocking + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nolocal.GNU + diff --git a/examples/Connection/blocking/Makefile b/examples/Connection/blocking/Makefile new file mode 100644 index 00000000000..4240e569478 --- /dev/null +++ b/examples/Connection/blocking/Makefile @@ -0,0 +1,414 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the Connection pattern tests +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +LIB = libSPIPE.a +SHLIB = libSPIPE.so + +BIN = test_spipe_connector \ + test_spipe_acceptor + +SRC = $(addsuffix .cpp,$(BIN)) +OBJ = $(SRC:%.cpp=$(VDIR)%.o) + +LSRC = SPIPE-connector.cpp \ + SPIPE-acceptor.cpp + +LDLIBS = -lSPIPE +LIBS = -lACE + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VLIB) $(VSHLIB) $(SHLIBA) $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.lib.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +LDFLAGS += -L./ + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/SPIPE-connector.o .shobj/SPIPE-connector.so: SPIPE-connector.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Connector.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/SPIPE.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SPIPE.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Connector.i \ + $(WRAPPER_ROOT)/ace/Get_Opt.h \ + SPIPE-connector.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch_Options.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Svc_Handler.cpp \ + $(WRAPPER_ROOT)/ace/Dynamic.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.i \ + $(WRAPPER_ROOT)/ace/Connector.h \ + $(WRAPPER_ROOT)/ace/Map_Manager.h \ + $(WRAPPER_ROOT)/ace/Map_Manager.cpp \ + $(WRAPPER_ROOT)/ace/Map_Manager.i \ + $(WRAPPER_ROOT)/ace/Strategies.h \ + $(WRAPPER_ROOT)/ace/Strategies.cpp \ + $(WRAPPER_ROOT)/ace/Connector.i \ + $(WRAPPER_ROOT)/ace/Connector.cpp +.obj/SPIPE-acceptor.o .shobj/SPIPE-acceptor.so: SPIPE-acceptor.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Acceptor.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/SPIPE.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SPIPE.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.i \ + $(WRAPPER_ROOT)/ace/Get_Opt.h \ + SPIPE-acceptor.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch_Options.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Svc_Handler.cpp \ + $(WRAPPER_ROOT)/ace/Dynamic.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.i \ + $(WRAPPER_ROOT)/ace/Acceptor.h \ + $(WRAPPER_ROOT)/ace/Strategies.h \ + $(WRAPPER_ROOT)/ace/Strategies.cpp \ + $(WRAPPER_ROOT)/ace/Acceptor.i \ + $(WRAPPER_ROOT)/ace/Acceptor.cpp +.obj/test_spipe_connector.o .shobj/test_spipe_connector.so: test_spipe_connector.cpp \ + $(WRAPPER_ROOT)/ace/SPIPE_Connector.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/SPIPE.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/SPIPE.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Connector.i \ + SPIPE-connector.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch_Options.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Svc_Handler.cpp \ + $(WRAPPER_ROOT)/ace/Dynamic.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.i \ + $(WRAPPER_ROOT)/ace/Connector.h \ + $(WRAPPER_ROOT)/ace/Map_Manager.h \ + $(WRAPPER_ROOT)/ace/Map_Manager.cpp \ + $(WRAPPER_ROOT)/ace/Map_Manager.i \ + $(WRAPPER_ROOT)/ace/Strategies.h \ + $(WRAPPER_ROOT)/ace/Strategies.cpp \ + $(WRAPPER_ROOT)/ace/Connector.i \ + $(WRAPPER_ROOT)/ace/Connector.cpp +.obj/test_spipe_acceptor.o .shobj/test_spipe_acceptor.so: test_spipe_acceptor.cpp \ + $(WRAPPER_ROOT)/ace/SPIPE_Acceptor.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/SPIPE.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/SPIPE.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.i \ + SPIPE-acceptor.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch_Options.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Svc_Handler.cpp \ + $(WRAPPER_ROOT)/ace/Dynamic.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.i \ + $(WRAPPER_ROOT)/ace/Acceptor.h \ + $(WRAPPER_ROOT)/ace/Strategies.h \ + $(WRAPPER_ROOT)/ace/Strategies.cpp \ + $(WRAPPER_ROOT)/ace/Acceptor.i \ + $(WRAPPER_ROOT)/ace/Acceptor.cpp + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/Connection/blocking/README b/examples/Connection/blocking/README new file mode 100644 index 00000000000..c7763e3ed04 --- /dev/null +++ b/examples/Connection/blocking/README @@ -0,0 +1,36 @@ +Presently, this directory contains only one example application for +SPIPEs. The test source code is contained in SPIPE-acceptor.h and +SPIPE-connector.h. + +The SPIPE-acceptor example illustrates how named pipes are used on NT. +Once the server establishes a connection to a single client, it spawns +a thread pool to handle incoming requests via the proactor event loop. +That is, a separate thread from the pool is used to process each +message sent by a client. The size of the thread pool can be +specified by command-line arguments. This example leverages the +queueing performed by the NT kernel to trivially implement a thread +pool architecture. + +test_spipe_acceptor has the following command-line arguments: + +test_spipe_acceptor -t <threads> + +<threads> specifies the size of the thread-pool running in the +proactor event loop. + +Here's how to run the tests: + +% test_spipe_acceptor -t 1000000 +starting up daemon test_sock_acceptor +Opening acepipe +hello + +% test_spipe_connector +starting up daemon test_sock_connector +Opening acepipe +activating 5 + +please enter input..: hello + +There are a number of other options that you can provide. Please see +the source code for details. diff --git a/examples/Connection/blocking/SPIPE-acceptor.cpp b/examples/Connection/blocking/SPIPE-acceptor.cpp new file mode 100644 index 00000000000..471ae4db8f4 --- /dev/null +++ b/examples/Connection/blocking/SPIPE-acceptor.cpp @@ -0,0 +1,179 @@ +#if !defined (SPIPE_ACCEPTOR_C) +// @(#)SPIPE-acceptor.cpp 1.1 10/18/96 + +#define SPIPE_ACCEPTOR_C + +#include "ace/Log_Msg.h" +#include "ace/SPIPE_Addr.h" +#include "ace/Time_Value.h" +#include "ace/SPIPE_Acceptor.h" +#include "ace/Get_Opt.h" +#include "SPIPE-acceptor.h" + +Svc_Handler::Svc_Handler (void) +{ +} + +Svc_Handler::~Svc_Handler (void) +{ +} + +int +Svc_Handler::open (void *) +{ + ACE_DEBUG ((LM_DEBUG, "client connected on handle %d\n", + this->peer ().get_handle ())); + return ACE_Service_Config::proactor ()->initiate + (this, ACE_Event_Handler::READ_MASK); +} + +ACE_Message_Block * +Svc_Handler::get_message (void) +{ + // An extra byte for null termination. + ACE_Message_Block *message = + new ACE_Message_Block (BUFSIZ + 1); + message->size (BUFSIZ); + return message; +} + +int +Svc_Handler::handle_input_complete (ACE_Message_Block *msg, + long bytes_transfered) +{ + if (bytes_transfered > 0) + { + msg->base ()[msg->length ()] = '\0'; + // Print out the message received from the server. + ACE_DEBUG ((LM_DEBUG, "(%t) message size %d.\n", msg->length ())); + ACE_DEBUG ((LM_DEBUG, "%s", msg->rd_ptr ())); + + return 1; // Reinvoke a recv() operation. + } + else + return -1; // Close down. +} + +IPC_Server::IPC_Server (void) + : n_threads_ (1), + rendezvous_ ("acepipe"), + done_handler_ (ACE_Sig_Handler_Ex (ACE_Service_Config::end_proactor_event_loop)) +{ +} + +IPC_Server::~IPC_Server (void) +{ +} + +int +IPC_Server::init (int argc, char *argv[]) +{ + if (this->parse_args (argc, argv) == -1) + return -1; + + ACE_DEBUG ((LM_DEBUG, "Opening %s\n", rendezvous_)); + + // Initialize named pipe listener. + if (this->open (ACE_SPIPE_Addr (rendezvous_)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), 1); + + // Register to receive shutdowns. + else if (ACE_Service_Config::reactor ()->register_handler + (SIGINT, &this->done_handler_) == -1) + return -1; + else + return 0; +} + +int +IPC_Server::fini (void) +{ + return 0; +} + +int +IPC_Server::parse_args (int argc, char *argv[]) +{ + ACE_LOG_MSG->open (argv[0]); + + ACE_Get_Opt get_opt (argc, argv, "ut:r:"); + + for (int c; (c = get_opt ()) != -1; ) + { + switch (c) + { + case 'r': + rendezvous_ = get_opt.optarg; + break; + case 't': + n_threads_ = ACE_OS::atoi (get_opt.optarg); + ACE_DEBUG ((LM_DEBUG, "%s == %d.\n", + get_opt.optarg, + n_threads_)); + ACE_Service_Config::proactor (2*n_threads_); + // This is a lame way to tell the proactor how many threads + // we'll be using. + break; + case 'u': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %n -t <threads>\n" + "-r <rendezvous>\n"), -1); + break; + } + } + + return 0; +} + +static void * +run_reactor_event_loop (void *) +{ + ACE_Thread_Control tc (ACE_Service_Config::thr_mgr ()); + ACE_DEBUG ((LM_DEBUG, "(%t) worker thread starting\n")); + + ACE_Service_Config::run_proactor_event_loop (); + return 0; +} + +int +IPC_Server::svc (void) +{ + // Performs the iterative server activities. + while (ACE_Service_Config::reactor_event_loop_done () == 0) + { + Svc_Handler sh; + + // Create a new SH endpoint, which performs all processing in + // its open() method (note no automatic restart if errno == + // EINTR). + if (this->accept (&sh, 0) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "accept"), 1); + // SH's destructor closes the stream implicitly but the + // listening endpoint stays open. + else + { + // Run single-threaded. + if (n_threads_ <= 1) + run_reactor_event_loop (0); + else + { + // Run thread pool. + if (ACE_Service_Config::thr_mgr ()->spawn_n (n_threads_, + run_reactor_event_loop, + 0, THR_NEW_LWP) + == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn_n"), 1); + + ACE_Service_Config::thr_mgr ()->wait (); + } + + ACE_DEBUG ((LM_DEBUG, "(%t) main thread exiting.\n")); + } + } + + /* NOTREACHED */ + return 0; +} + +#endif /* SPIPE_ACCEPTOR_C */ diff --git a/examples/Connection/blocking/SPIPE-acceptor.h b/examples/Connection/blocking/SPIPE-acceptor.h new file mode 100644 index 00000000000..42d0e106ede --- /dev/null +++ b/examples/Connection/blocking/SPIPE-acceptor.h @@ -0,0 +1,63 @@ +/* -*- C++ -*- */ +// @(#)SPIPE-acceptor.h 1.1 10/18/96 + +#if !defined (SP_ACCEPTOR_H) +#define SP_ACCEPTOR_H + +#include "ace/Svc_Handler.h" +#include "ace/Acceptor.h" +#include "ace/SPIPE_Stream.h" +#include "ace/SPIPE_Acceptor.h" + +// This is the class that does the work once the ACE_Oneshot_Acceptor +// has accepted a connection. + +class Svc_Handler : public ACE_Svc_Handler <ACE_SPIPE_STREAM, ACE_NULL_SYNCH> +{ +public: + Svc_Handler (void); + ~Svc_Handler (void); + + virtual int open (void *); + + virtual ACE_Message_Block *get_message (void); + + virtual int handle_input_complete (ACE_Message_Block *msg, + long bytes_transfered); + // Handle data from the client. + +private: +}; + +class IPC_Server : public ACE_Oneshot_Acceptor<Svc_Handler, ACE_SPIPE_ACCEPTOR> +{ +public: + IPC_Server (void); + ~IPC_Server (void); + + // = Dynamic linking hooks. + virtual int init (int argc, char *argv[]); + // Initialize the network server. + + virtual int fini (void); + // Close down the server. + + virtual int svc (void); + // Run the interative service. + +private: + int parse_args (int argc, char *argv[]); + // Parse command-line arguments. + + int n_threads_; + // Size of thread pool to use. + + const char *rendezvous_; + // Meeting place for pipe. + + ACE_Sig_Adapter done_handler_; + // Keeps track of when we shut down due to receipt of the SIGINT + // signal. +}; + +#endif /* SP_ACCEPTOR_H */ diff --git a/examples/Connection/blocking/SPIPE-connector.cpp b/examples/Connection/blocking/SPIPE-connector.cpp new file mode 100644 index 00000000000..584c16cd9f2 --- /dev/null +++ b/examples/Connection/blocking/SPIPE-connector.cpp @@ -0,0 +1,182 @@ +#if !defined (SPIPE_CONNECTOR_C) +// @(#)SPIPE-connector.cpp 1.1 10/18/96 + +#define SPIPE_CONNECTOR_C + +#include "ace/Log_Msg.h" +#include "ace/SPIPE_Addr.h" +#include "ace/SPIPE_Connector.h" +#include "ace/Get_Opt.h" +#include "SPIPE-connector.h" + +Peer_Handler::Peer_Handler (int iterations) + : iterations_ (iterations) +{ +} + +Peer_Handler::~Peer_Handler () +{ +} + +int +Peer_Handler::open (void *) +{ + ACE_DEBUG ((LM_DEBUG, "activating %d\n", this->get_handle ())); + + // If iterations_ has not been set, read from stdin. + if (iterations_ == 0) + { + this->display_menu (); + 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")); + } + else // If iterations_ has been set, send iterations_ buffers. + { + char *buffer = + "Oh give me a home\n" + "Where the buffalo roam,\n" + "And the deer and the antelope play.\n" + "Where seldom is heard\n" + "A discouraging word,\n" + "And the skies are not cloudy all day.\n"; + int length = ACE_OS::strlen (buffer); + + while (iterations_-- > 0 + && this->peer ().send_n (buffer, length) == length) + continue; + + return this->peer ().close (); + } +} + +int +Peer_Handler::handle_input (ACE_HANDLE) +{ + char buf[BUFSIZ]; + + ssize_t n = ACE_OS::read (ACE_STDIN, buf, sizeof buf); + + if (n > 0) + if (this->peer ().send (buf, n) != n) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "write failed"), -1); + else if (n == 0) /* Explicitly close the connection. */ + { + if (this->peer ().close () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), 1); + return -1; + } + else + this->display_menu (); + return 0; +} + +int +Peer_Handler::handle_close (ACE_HANDLE handle, + ACE_Reactor_Mask mask) +{ + ACE_DEBUG ((LM_DEBUG, "Shutting down\n")); + return 0; +} + +ACE_HANDLE +Peer_Handler::get_handle (void) const +{ + return this->peer ().get_handle (); +} + +void +Peer_Handler::display_menu (void) +{ + ACE_DEBUG ((LM_DEBUG, "\nplease enter input..: ")); +} + +IPC_Client::IPC_Client (void) + : rendezvous_ ("acepipe"), + iterations_ (0), + done_handler_ (ACE_Sig_Handler_Ex (ACE_Service_Config::end_proactor_event_loop)) +{ +} + +IPC_Client::~IPC_Client (void) +{ +} + +// Dynamic linking hooks. + +int +IPC_Client::init (int argc, char *argv[]) +{ + if (this->parse_args (argc, argv) == -1) + return -1; + // Handle signals through the ACE_Reactor. + else if (ACE_Service_Config::reactor ()->register_handler + (SIGINT, &this->done_handler_) == -1) + return -1; + + ACE_DEBUG ((LM_DEBUG, "Opening %s\n", rendezvous_)); + + // Connect to the peer, reusing the local addr if necessary. + if (this->connect (new Peer_Handler (iterations_), + ACE_SPIPE_Addr (rendezvous_), + ACE_Synch_Options::defaults, + *((ACE_SPIPE_Addr *) &ACE_Addr::sap_any), + 0, + O_RDWR | FILE_FLAG_OVERLAPPED, + 0) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "connect"), -1); + + return 0; +} + +int +IPC_Client::fini (void) +{ + return 0; +} + +int +IPC_Client::svc (void) +{ + ACE_Service_Config::run_reactor_event_loop (); + return 0; +} + +int +IPC_Client::handle_close (ACE_HANDLE, ACE_Reactor_Mask) +{ + return 0; +} + +int +IPC_Client::parse_args (int argc, char *argv[]) +{ + ACE_LOG_MSG->open (argv[0]); + + ACE_Get_Opt get_opt (argc, argv, "ui:r:"); + + for (int c; (c = get_opt ()) != -1; ) + { + switch (c) + { + case 'r': + rendezvous_ = get_opt.optarg; + break; + case 'i': + iterations_ = ACE_OS::atoi (get_opt.optarg); + break; + case 'u': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %n -i <iterations>\n" + "-r <rendezvous>\n"), -1); + break; + } + } + + return 0; +} + + +#endif /* SPIPE_CONNECTOR */ diff --git a/examples/Connection/blocking/SPIPE-connector.h b/examples/Connection/blocking/SPIPE-connector.h new file mode 100644 index 00000000000..81525f0a0eb --- /dev/null +++ b/examples/Connection/blocking/SPIPE-connector.h @@ -0,0 +1,75 @@ +/* -*- C++ -*- */ +// @(#)SPIPE-connector.h 1.1 10/18/96 + +#if !defined (SP_CONNECTOR_H) +#define SP_CONNECTOR_H + +#include "ace/Svc_Handler.h" +#include "ace/SPIPE_Stream.h" +#include "ace/Connector.h" +#include "ace/SPIPE_Connector.h" + +class Peer_Handler : public ACE_Svc_Handler<ACE_SPIPE_STREAM, ACE_NULL_SYNCH> +{ +public: + // = Initialization + + Peer_Handler (int iterations); + // <iterations> is the number of buffers to send. If <iterations> + // == 0, then read from stdin. + + ~Peer_Handler (void); + + virtual int open (void * = 0); + // Activate the handler when connection is established. + + // = Demultiplexing hooks. + virtual int handle_input (ACE_HANDLE); + virtual int handle_close (ACE_HANDLE handle = ACE_INVALID_HANDLE, + ACE_Reactor_Mask mask = ACE_Event_Handler::RWE_MASK); + + virtual ACE_HANDLE get_handle (void) const; + +private: + void display_menu (void); + + int iterations_; + // No. of buffers to send. +}; + +class IPC_Client : public ACE_Connector<Peer_Handler, ACE_SPIPE_CONNECTOR> +{ +public: + // Initialization + IPC_Client (void); + ~IPC_Client (void); + + // = Dynamic linking hooks. + virtual int init (int argc, char *argv[]); + // Initialize the IPC client. + + virtual int fini (void); + // Destroy the IPC client. + + virtual int svc (void); + // Run the svc. + + virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask); + // Report connection errors. + +private: + int parse_args (int argc, char *argv[]); + // Parse command-line arguments. + + int iterations_; + // Number of times to send a buffer. + + const char *rendezvous_; + // Meeting place for pipe. + + ACE_Sig_Adapter done_handler_; + // Keeps track of when we shut down due to receipt of the SIGINT + // signal. +}; + +#endif /* SP_CONNECTOR_H */ diff --git a/examples/Connection/blocking/test_spipe_acceptor.cpp b/examples/Connection/blocking/test_spipe_acceptor.cpp new file mode 100644 index 00000000000..2ef842022f8 --- /dev/null +++ b/examples/Connection/blocking/test_spipe_acceptor.cpp @@ -0,0 +1,22 @@ +// ACE_SPIPE Server. +// @(#)test_spipe_acceptor.cpp 1.1 10/18/96 + + +#include "ace/SPIPE_Acceptor.h" +#include "ace/SPIPE_Addr.h" +#include "SPIPE-acceptor.h" + +int +main (int argc, char *argv[]) +{ + // Perform Service_Config initializations + ACE_Service_Config daemon (argv[0]); + + IPC_Server acceptor; + + if (acceptor.init (argc, argv) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "init"), -1); + + return acceptor.svc (); +} + diff --git a/examples/Connection/blocking/test_spipe_connector.cpp b/examples/Connection/blocking/test_spipe_connector.cpp new file mode 100644 index 00000000000..2dbc1b7d5e0 --- /dev/null +++ b/examples/Connection/blocking/test_spipe_connector.cpp @@ -0,0 +1,22 @@ +// ACE_SPIPE Client. +// @(#)test_spipe_connector.cpp 1.1 10/18/96 + + +#include "ace/SPIPE_Connector.h" +#include "ace/SPIPE_Addr.h" +#include "SPIPE-connector.h" + +int +main (int argc, char *argv[]) +{ + // Perform Service_Config initializations + ACE_Service_Config daemon (argv[0]); + + IPC_Client peer_connector; + + if (peer_connector.init (argc, argv) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "init"), -1); + + return peer_connector.svc (); +} + diff --git a/examples/Connection/misc/Makefile b/examples/Connection/misc/Makefile new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/examples/Connection/misc/Makefile diff --git a/examples/Connection/misc/test_upipe.cpp b/examples/Connection/misc/test_upipe.cpp new file mode 100644 index 00000000000..84e10fae03e --- /dev/null +++ b/examples/Connection/misc/test_upipe.cpp @@ -0,0 +1,176 @@ +// This short program illustrates in implementation of the classic +// @(#)test_upipe.cpp 1.1 10/18/96 + +// "bounded buffer" program using ACE_UPIPEs. This program also shows +// how the ACE_Connector and ACE_Acceptor patterns work when used with +// ACE_UPIPEs. + +// Enable tracing +#include "ace/Log_Msg.h" +#include "ace/Acceptor.h" +#include "ace/Connector.h" +#include "ace/UPIPE_Acceptor.h" +#include "ace/UPIPE_Connector.h" +#include "ace/UPIPE_Addr.h" + +#if defined (ACE_HAS_THREADS) + +typedef ACE_Svc_Handler <ACE_UPIPE_STREAM, ACE_NULL_SYNCH> SVC_HANDLER; + +class Server_Service : public SVC_HANDLER + // = TITLE + // Defines the interface for a service that recvs data from its + // client and writes the data to its stdout. +{ +public: + Server_Service (ACE_Thread_Manager * = 0) {} + virtual int open (void *) + { + ACE_TRACE ("Server_Service::open"); + return 0; + } + + virtual int svc (void) + { + ACE_TRACE ("Server_Service::svc"); + + char buf[BUFSIZ]; + ssize_t n; + + while ((n = this->peer ().recv (buf, sizeof buf)) > 0) + ::write (1, buf, n); + + return 0; + } +}; + +class Server : public ACE_Strategy_Acceptor <Server_Service, ACE_UPIPE_ACCEPTOR> + // = TITLE + // Defines the interface for a factory that accepts connections + // and creates/activates Server_Service objects. +{ +public: + Server (ACE_Thread_Manager *thr_mgr, + ACE_Reactor *reactor) + : reactor_ (reactor), + thr_mgr_ (thr_mgr) + { + ACE_TRACE ("Server::Server"); + } + + virtual int init (int argc, char *argv[]) + { + ACE_TRACE ("Server::init"); + const char *l_addr = argc > 1 ? argv[1] : ACE_DEFAULT_RENDEZVOUS; + + ACE_UPIPE_Addr local_addr (l_addr); + + if (this->thr_strategy_.open (this->thr_mgr_, THR_DETACHED | THR_NEW_LWP) == -1) + return -1; + else if (this->open (local_addr, this->reactor_, + 0, 0, &this->thr_strategy_) == -1) + return -1; + + // Give server a chance to register the STREAM pipe. + ACE_OS::sleep (ACE_Time_Value (4)); + return 0; + } + +private: + ACE_Reactor *reactor_; + // Our instance of the reactor. + + ACE_Thread_Manager *thr_mgr_; + // Our instance of a thread manager. + + ACE_Thread_Strategy<Server_Service> thr_strategy_; + // Our concurrency strategy. +}; + +class Client_Service : public SVC_HANDLER + // = TITLE + // Defines the interface for a service that recvs data from its + // stdin and forward the data to its server. +{ +public: + Client_Service (ACE_Thread_Manager *thr_mgr) + : SVC_HANDLER (thr_mgr) + { + ACE_TRACE ("Client_Service::Client_Service"); + } + + virtual int open (void *) + { + ACE_TRACE ("Client_Service::open"); + return this->activate (THR_DETACHED | THR_NEW_LWP); + } + + virtual int svc (void) + { + ACE_TRACE ("Client_Service::svc"); + char buf[BUFSIZ]; + ssize_t n; + + while ((n = ACE_OS::read (ACE_STDIN, buf, sizeof buf)) > 0) + this->peer ().send (buf, sizeof buf); + + this->peer ().close (); + return 0; + } +}; + +class Client : public ACE_Connector <Client_Service, ACE_UPIPE_CONNECTOR> + // = TITLE + // Defines the interface for a factory that connects + // a Client_Service with a Server. +{ +public: + Client (ACE_Thread_Manager *thr_mgr) + : thr_mgr_ (thr_mgr) + { + ACE_TRACE ("Client::Client"); + } + + virtual int init (int argc, char *argv[]) + { + ACE_TRACE ("Client::init"); + + char *r_addr = argc > 1 ? argv[1] : ACE_DEFAULT_RENDEZVOUS; + + ACE_UPIPE_Addr remote_addr (r_addr); + + return this->connect (new Client_Service (this->thr_mgr_), remote_addr); + } + +private: + ACE_Thread_Manager *thr_mgr_; +}; + +//---------------------------------------- + +int main (int argc, char *argv[]) +{ + ACE_Service_Config svc_conf; + ACE_Thread_Manager thr_mgr; + + Client peer_connector (&thr_mgr); + Server peer_acceptor (&thr_mgr, ACE_Service_Config::reactor ()); + + // Establish the connection between Acceptor and Connector. + + if (peer_acceptor.init (argc, argv) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "init"), -1); + else if (peer_connector.init (argc, argv) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "init"), -1); + + // Wait for threads to exit. + thr_mgr.wait (); + return 0; +} +#else +int +main (void) +{ + ACE_ERROR_RETURN ((LM_ERROR, "your platform does not support threads\n"), 1); +} +#endif /* ACE_HAS_THREADS */ diff --git a/examples/Connection/non_blocking/CPP-acceptor.cpp b/examples/Connection/non_blocking/CPP-acceptor.cpp new file mode 100644 index 00000000000..378fe347eb8 --- /dev/null +++ b/examples/Connection/non_blocking/CPP-acceptor.cpp @@ -0,0 +1,172 @@ +#if !defined (CPP_ACCEPTOR_C) +// @(#)CPP-acceptor.cpp 1.1 10/18/96 + +#define CPP_ACCEPTOR_C + +#include "ace/Log_Msg.h" +#include "ace/Service_Config.h" +#include "CPP-acceptor.h" + +#define PR_ST_1 ACE_PEER_STREAM_1 +#define PR_ST_2 ACE_PEER_STREAM_2 +#define PR_AC_1 ACE_PEER_ACCEPTOR_1 +#define PR_AC_2 ACE_PEER_ACCEPTOR_2 +#define PR_AD ACE_PEER_ACCEPTOR_ADDR +#define SH SVC_HANDLER + +template <PR_ST_1> +Svc_Handler<PR_ST_2>::Svc_Handler (ACE_Reactor *r) + : SVC_HANDLER (0, 0, r) +{ +} + +template <PR_ST_1> int +Svc_Handler<PR_ST_2>::close (u_long) +{ + ACE_DEBUG ((LM_DEBUG, "calling Svc_Handler close\n")); + + // Free up the handle. + this->peer ().close (); + return 0; +} + +template <PR_ST_1> int +Svc_Handler<PR_ST_2>::open (void *) +{ + PR_AD client_addr; + char buf[BUFSIZ]; + + if (this->peer ().get_remote_addr (client_addr) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "get_remote_addr"), -1); + else if (client_addr.addr_to_string (buf, sizeof buf) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "addr_to_string"), -1); + else + ACE_DEBUG ((LM_DEBUG, "client addr %s on handle %d\n", + buf, this->peer ().get_handle ())); + + // Process the connection immediately since we are an interative + // server. + return this->handle_input (); +} + +// Receive and process the data from the client. + +template <PR_ST_1> int +Svc_Handler<PR_ST_2>::handle_input (ACE_HANDLE) +{ + char buf[BUFSIZ]; + + // Read data from client (terminate on error). + + cerr << "in handle_input" << endl; + for (int r_bytes; (r_bytes = this->peer ().recv (buf, sizeof buf)) > 0; ) + if (ACE_OS::write (ACE_STDOUT, buf, r_bytes) != r_bytes) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE::send_n"), -1); + + // Send back ack. + if (this->peer ().send_n ("", 1) != 1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send_n"), -1); + return 0; +} + +template <PR_ST_1> int +Svc_Handler<PR_ST_2>::handle_timeout (const ACE_Time_Value &, + const void *) +{ + ACE_DEBUG ((LM_DEBUG, "%p\n", "handle_timeout")); + return 0; +} + +template <class SH, PR_AC_1> int +IPC_Server<SH, PR_AC_2>::init (int argc, char *argv[]) +{ + const char *local_addr = argc > 1 ? argv[1] : ACE_DEFAULT_SERVER_PORT_STR; + ACE_Time_Value timeout (argc > 2 ? ACE_OS::atoi (argv[2]) : ACE_DEFAULT_TIMEOUT); + int use_reactor = argc > 3 ? ACE_Synch_Options::USE_REACTOR : 0; + + this->options_.set (ACE_Synch_Options::USE_TIMEOUT | use_reactor, timeout); + + if (this->server_addr_.set (local_addr) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "set"), -1); + // Call down to the ACCEPTOR's open() method to do the initialization. + if (this->inherited::open (this->server_addr_, + use_reactor ? ACE_Service_Config::reactor () : 0) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); + + // Handle SIGINT signal through the ACE_Reactor. + else if (ACE_Service_Config::reactor ()->register_handler + (SIGINT, &this->done_handler_) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "register_handler"), -1); + + // 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")); + else + return 0; +} + +template <class SH, PR_AC_1> +IPC_Server<SH, PR_AC_2>::IPC_Server (void) + : done_handler_ (ACE_Sig_Handler_Ex (ACE_Service_Config::end_reactor_event_loop)) +{ +} + +template <class SH, PR_AC_1> int +IPC_Server<SH, PR_AC_2>::fini (void) +{ + return 0; +} + +template <class SH, PR_AC_1> +IPC_Server<SH, PR_AC_2>::~IPC_Server (void) +{ +} + +// Run the interative service. + +template <class SH, PR_AC_1> int +IPC_Server<SH, PR_AC_2>::svc (void) +{ + char buf[BUFSIZ]; + + if (this->server_addr_.addr_to_string (buf, sizeof buf) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "addr_to_string"), -1); + else + ACE_DEBUG ((LM_DEBUG, "starting server addr %s on handle %d\n", + buf, this->get_handle ())); + + // Performs the iterative server activities. + + while (ACE_Service_Config::reactor_event_loop_done () == 0) + { + SH sh (this->reactor ()); + + // Create a new SH endpoint, which performs all processing in + // its open() method (note no automatic restart if errno == + // EINTR). + + if (this->accept (&sh, 0, this->options_, 0) == -1) + { + if (errno == EWOULDBLOCK && this->reactor ()) + this->reactor ()->handle_events (); + else + ACE_ERROR ((LM_ERROR, "%p on handle %d\n", + "accept", this->acceptor ().get_handle ())); + } + + // SH's destructor closes the stream implicitly but the + // listening endpoint stays open. + } + + /* NOTREACHED */ + return 0; +} + +#undef PR_ST_1 +#undef PR_ST_2 +#undef PR_AC_1 +#undef PR_AC_2 +#undef PR_AD +#undef SH +#endif /* CPP_ACCEPTOR_C */ diff --git a/examples/Connection/non_blocking/CPP-acceptor.h b/examples/Connection/non_blocking/CPP-acceptor.h new file mode 100644 index 00000000000..75f01ad9bf2 --- /dev/null +++ b/examples/Connection/non_blocking/CPP-acceptor.h @@ -0,0 +1,70 @@ +/* -*- C++ -*- */ +// @(#)CPP-acceptor.h 1.1 10/18/96 + +#if !defined (CPP_ACCEPTOR_H) +#define CPP_ACCEPTOR_H + +#include "ace/Acceptor.h" + +// This is the class that does the work once the ACE_Oneshot_Acceptor +// has accepted a connection. + +template <ACE_PEER_STREAM_1> +class Svc_Handler : public ACE_Svc_Handler <ACE_PEER_STREAM_2, ACE_NULL_SYNCH> +{ +public: + // = Initialization method. + Svc_Handler (ACE_Reactor *r); + + virtual int open (void *); + // Perform the work of the SVC_HANDLER. + + virtual int handle_input (ACE_HANDLE = ACE_INVALID_HANDLE); + // Handle data from the client. + + virtual int close (u_long); + // Called if ACE_Svc_Handler is closed down unexpectedly. + + virtual int handle_timeout (const ACE_Time_Value &, const void *arg); + // Handles acceptor timeouts. + +private: + typedef ACE_Svc_Handler <ACE_PEER_STREAM_2, ACE_NULL_SYNCH> SVC_HANDLER; +}; + +template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> +class IPC_Server : public ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2> +{ +public: + // = Initialization and termination. + IPC_Server (void); + ~IPC_Server (void); + + // = Dynamic linking hooks. + virtual int init (int argc, char *argv[]); + // Initialize the network server. + + virtual int fini (void); + // Close down the server. + + virtual int svc (void); + // Run the interative service. + +private: + typedef ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2> inherited; + + PEER_ADDR server_addr_; + // Address of this server. + + ACE_Synch_Options options_; + // Options that this server is using. + + ACE_Sig_Adapter done_handler_; + // Keeps track of when we shut down due to receipt of the SIGINT + // signal. +}; + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "CPP-acceptor.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ +#endif /* CPP_ACCEPTOR_H */ diff --git a/examples/Connection/non_blocking/CPP-connector.cpp b/examples/Connection/non_blocking/CPP-connector.cpp new file mode 100644 index 00000000000..c77a36f248c --- /dev/null +++ b/examples/Connection/non_blocking/CPP-connector.cpp @@ -0,0 +1,219 @@ +#if !defined (CPP_CONNECTOR_C) +// @(#)CPP-connector.cpp 1.1 10/18/96 + +#define CPP_CONNECTOR_C + +#include "ace/Log_Msg.h" +#include "CPP-connector.h" + +#define PR_ST_1 ACE_PEER_STREAM_1 +#define PR_ST_2 ACE_PEER_STREAM_2 +#define PR_CO_1 ACE_PEER_CONNECTOR_1 +#define PR_CO_2 ACE_PEER_CONNECTOR_2 +#define PR_AD ACE_PEER_CONNECTOR_ADDR +#define SH SVC_HANDLER + +template <PR_ST_1> +Peer_Handler<PR_ST_2>::Peer_Handler (ACE_Reactor *r) + : action_ (&Peer_Handler<PR_ST_2>::idle) +{ + this->reactor (r); +} + +template <PR_ST_1> int +Peer_Handler<PR_ST_2>::open (void *) +{ + ACE_DEBUG ((LM_DEBUG, "activating %d\n", this->get_handle ())); + this->action_ = &Peer_Handler<PR_ST_2>::connected; + + if (this->reactor ()) + this->reactor ()->register_handler (this, ACE_Event_Handler::WRITE_MASK); + else + { + while (this->connected () != -1) + continue; + + this->handle_close (0, ACE_Event_Handler::READ_MASK); + } + return 0; +} + +template <PR_ST_1> ACE_HANDLE +Peer_Handler<PR_ST_2>::get_handle (void) const +{ + return this->peer ().get_handle (); +} + +template <PR_ST_1> int +Peer_Handler<PR_ST_2>::disconnecting (void) +{ + char buf[BUFSIZ]; + int n; + + if ((n = this->peer ().recv (buf, sizeof buf)) > 0) + ACE_OS::write (ACE_STDOUT, buf, n); + this->action_ = &Peer_Handler<PR_ST_2>::idle; + return -1; +} + +template <PR_ST_1> int +Peer_Handler<PR_ST_2>::idle (void) +{ + ACE_DEBUG ((LM_DEBUG, "idle!\n")); + return 0; +} + +template <PR_ST_1> int +Peer_Handler<PR_ST_2>::connected (void) +{ + char buf[BUFSIZ]; + int n; + + ACE_DEBUG ((LM_DEBUG, "please enter input..: ")); + + if ((n = ACE_OS::read (ACE_STDIN, buf, sizeof buf)) > 0 + && this->peer ().send_n (buf, n) != n) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "write failed"), -1); + else if (n == 0) /* Explicitly close the connection. */ + { + if (this->peer ().close () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), 1); + this->action_ = &Peer_Handler<PR_ST_2>::disconnecting; + return -1; + } + else + return 0; +} + +template <PR_ST_1> int +Peer_Handler<PR_ST_2>::stdio (void) +{ + char buf[BUFSIZ]; + int n; + + ACE_DEBUG ((LM_DEBUG, "stdio!\n")); + + ACE_DEBUG ((LM_DEBUG, "please enter input..: ")); + + if ((n = ACE_OS::read (ACE_STDIN, buf, sizeof buf)) > 0) + { + ACE_OS::write (ACE_STDOUT, buf, n); + return 0; + } + else + return -1; +} + +template <PR_ST_1> int +Peer_Handler<PR_ST_2>::handle_output (ACE_HANDLE) +{ + ACE_DEBUG ((LM_DEBUG, "in handle_output\n")); + + return (this->*action_) (); +} + +template <PR_ST_1> int +Peer_Handler<PR_ST_2>::handle_input (ACE_HANDLE) +{ + ACE_DEBUG ((LM_DEBUG, "in handle_input\n")); + + return (this->*action_) (); +} + +template <PR_ST_1> int +Peer_Handler<PR_ST_2>::handle_close (ACE_HANDLE, + ACE_Reactor_Mask mask) +{ + ACE_DEBUG ((LM_DEBUG, "closing down (%d)\n", mask)); + if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK)) + { + this->action_ = &Peer_Handler<PR_ST_2>::stdio; + this->peer ().close (); + ACE_OS::rewind (stdin); + return this->reactor () && this->reactor ()->register_handler + (ACE_STDIN, this, ACE_Event_Handler::READ_MASK); + } + else if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK)) + delete this; + return 0; + +} + +template <class SH, PR_CO_1> int +IPC_Client<SH, PR_CO_2>::svc (void) +{ + if (this->reactor ()) + ACE_Service_Config::run_reactor_event_loop (); + + return 0; +} + +template <class SH, PR_CO_1> int +IPC_Client<SH, PR_CO_2>::fini (void) +{ + return 0; +} + +template <class SH, PR_CO_1> +IPC_Client<SH, PR_CO_2>::IPC_Client (void) + : done_handler_ (ACE_Sig_Handler_Ex (ACE_Service_Config::end_reactor_event_loop)) +{ +} + +template <class SH, PR_CO_1> int +IPC_Client<SH, PR_CO_2>::init (int argc, char *argv[]) +{ + // Call down to the CONNECTOR's open() method to do the initialization. + this->inherited::open (ACE_Service_Config::reactor ()); + + char *r_addr = argc > 1 ? argv[1] : + ACE_SERVER_ADDRESS (ACE_DEFAULT_SERVER_HOST, ACE_DEFAULT_SERVER_PORT_STR); + ACE_Time_Value timeout (argc > 2 ? ACE_OS::atoi (argv[2]) : ACE_DEFAULT_TIMEOUT); + char *l_addr = argc > 3 ? argv[3] : ACE_DEFAULT_LOCAL_PORT_STR; + + // Handle signals through the ACE_Reactor. + if (ACE_Service_Config::reactor ()->register_handler + (SIGINT, &this->done_handler_) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "register_handler"), -1); + + PR_AD remote_addr (r_addr); + PR_AD local_addr (l_addr); + + this->options_.set (ACE_Synch_Options::USE_REACTOR, timeout); + + // Connect to the peer, reusing the local addr if necessary. + if (this->connect (new SH (this->reactor ()), remote_addr, + this->options_, local_addr, 1) == -1 + && errno != EWOULDBLOCK) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "connect"), -1); + return 0; +} + +template <class SH, PR_CO_1> +IPC_Client<SH, PR_CO_2>::~IPC_Client (void) +{ +} + +template <class SH, PR_CO_1> int +IPC_Client<SH, PR_CO_2>::handle_close (ACE_HANDLE h, + ACE_Reactor_Mask) +{ + if (h >= 0) + ACE_ERROR ((LM_ERROR, "%p on %d\n", "connection failed", h)); + else // We are closing down the connector. + { + ACE_DEBUG ((LM_DEBUG, "closing down IPC_Client\n")); + this->inherited::handle_close (); + } + + ACE_Service_Config::end_reactor_event_loop (); + return 0; +} + +#undef PR_ST_1 +#undef PR_ST_2 +#undef PR_CO_1 +#undef PR_CO_2 +#undef PR_AD +#undef SH +#endif /* CPP_CONNECTOR_C */ diff --git a/examples/Connection/non_blocking/CPP-connector.h b/examples/Connection/non_blocking/CPP-connector.h new file mode 100644 index 00000000000..021fbb85661 --- /dev/null +++ b/examples/Connection/non_blocking/CPP-connector.h @@ -0,0 +1,77 @@ +/* -*- C++ -*- */ +// @(#)CPP-connector.h 1.1 10/18/96 + +#if !defined (CPP_CONNECTOR_H) +#define CPP_CONNECTOR_H + +#include "ace/Service_Config.h" +#include "ace/Connector.h" + +template <ACE_PEER_STREAM_1> +class Peer_Handler : public ACE_Svc_Handler<ACE_PEER_STREAM_2, ACE_SYNCH> +{ +public: + Peer_Handler (ACE_Reactor *r); + + virtual int open (void * = 0); + // Activate the handler when connection is established. + + // = Demultiplexing hooks. + virtual int handle_output (ACE_HANDLE); + virtual int handle_input (ACE_HANDLE); + virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask mask); + + virtual ACE_HANDLE get_handle (void) const; + +protected: + // = These methods implement the State pattern. + int idle (void); + int connected (void); + int disconnecting (void); + int stdio (void); + + int (Peer_Handler<ACE_PEER_STREAM_2>::*action_) (void); + // Keeps track of which state we are in. + +private: + // = Disallow these methods... + virtual int put (ACE_Message_Block *, ACE_Time_Value *) { return 0; } + virtual int svc (void) { return 0; } +}; + +template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> +class IPC_Client : public ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2> +{ +public: + // = Initialization and termination methods. + IPC_Client (void); + ~IPC_Client (void); + + // = Dynamic linking hooks. + virtual int init (int argc, char *argv[]); + // Initialize the IPC client. + + virtual int fini (void); + // Destroy the IPC client. + + virtual int svc (void); + // Run the svc. + + virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask); + // Report connection errors. + +private: + typedef ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2> inherited; + + ACE_Synch_Options options_; + // Options for the active connection factory. + + ACE_Sig_Adapter done_handler_; + // Keeps track of when we shut down due to receipt of the SIGINT + // signal. +}; + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "CPP-connector.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ +#endif /* CPP_CONNECTOR_H */ diff --git a/examples/Connection/non_blocking/Makefile b/examples/Connection/non_blocking/Makefile new file mode 100644 index 00000000000..3098b81802c --- /dev/null +++ b/examples/Connection/non_blocking/Makefile @@ -0,0 +1,756 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the Connection pattern tests +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +LIB = libConn.a +SHLIB = libConn.so + +BIN = test_sock_connector \ + test_sock_acceptor \ + test_tli_connector \ + test_tli_acceptor \ + test_spipe_connector \ + test_spipe_acceptor + +SRC = $(addsuffix .cpp,$(BIN)) +OBJ = $(SRC:%.cpp=$(VDIR)%.o) + +LSRC = CPP-connector.cpp \ + CPP-acceptor.cpp + +LDLIBS = -lConn +LIBS = -lACE + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VLIB) $(VSHLIB) $(SHLIBA) $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.lib.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +LDFLAGS += -L./ + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/CPP-connector.o .shobj/CPP-connector.so: CPP-connector.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + CPP-connector.h \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Connector.h \ + $(WRAPPER_ROOT)/ace/Map_Manager.h \ + $(WRAPPER_ROOT)/ace/Map_Manager.cpp \ + $(WRAPPER_ROOT)/ace/Map_Manager.i \ + $(WRAPPER_ROOT)/ace/Svc_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch_Options.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Svc_Handler.cpp \ + $(WRAPPER_ROOT)/ace/Dynamic.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.i \ + $(WRAPPER_ROOT)/ace/Strategies.h \ + $(WRAPPER_ROOT)/ace/Strategies.cpp \ + $(WRAPPER_ROOT)/ace/Connector.i \ + $(WRAPPER_ROOT)/ace/Connector.cpp \ + CPP-connector.cpp +.obj/CPP-acceptor.o .shobj/CPP-acceptor.so: CPP-acceptor.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + CPP-acceptor.h \ + $(WRAPPER_ROOT)/ace/Acceptor.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch_Options.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Svc_Handler.cpp \ + $(WRAPPER_ROOT)/ace/Dynamic.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.i \ + $(WRAPPER_ROOT)/ace/Strategies.h \ + $(WRAPPER_ROOT)/ace/Strategies.cpp \ + $(WRAPPER_ROOT)/ace/Acceptor.i \ + $(WRAPPER_ROOT)/ace/Acceptor.cpp \ + CPP-acceptor.cpp +.obj/test_sock_connector.o .shobj/test_sock_connector.so: test_sock_connector.cpp \ + $(WRAPPER_ROOT)/ace/SOCK_Connector.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/SOCK_Connector.i \ + CPP-connector.h \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Connector.h \ + $(WRAPPER_ROOT)/ace/Map_Manager.h \ + $(WRAPPER_ROOT)/ace/Map_Manager.cpp \ + $(WRAPPER_ROOT)/ace/Map_Manager.i \ + $(WRAPPER_ROOT)/ace/Svc_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch_Options.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Svc_Handler.cpp \ + $(WRAPPER_ROOT)/ace/Dynamic.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.i \ + $(WRAPPER_ROOT)/ace/Strategies.h \ + $(WRAPPER_ROOT)/ace/Strategies.cpp \ + $(WRAPPER_ROOT)/ace/Connector.i \ + $(WRAPPER_ROOT)/ace/Connector.cpp \ + CPP-connector.cpp +.obj/test_sock_acceptor.o .shobj/test_sock_acceptor.so: test_sock_acceptor.cpp \ + $(WRAPPER_ROOT)/ace/SOCK_Acceptor.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + CPP-acceptor.h \ + $(WRAPPER_ROOT)/ace/Acceptor.h \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch_Options.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Svc_Handler.cpp \ + $(WRAPPER_ROOT)/ace/Dynamic.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.i \ + $(WRAPPER_ROOT)/ace/Strategies.h \ + $(WRAPPER_ROOT)/ace/Strategies.cpp \ + $(WRAPPER_ROOT)/ace/Acceptor.i \ + $(WRAPPER_ROOT)/ace/Acceptor.cpp \ + CPP-acceptor.cpp +.obj/test_tli_connector.o .shobj/test_tli_connector.so: test_tli_connector.cpp \ + $(WRAPPER_ROOT)/ace/TLI_Connector.h \ + $(WRAPPER_ROOT)/ace/TLI_Stream.h \ + $(WRAPPER_ROOT)/ace/TLI.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/TLI.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/TLI_Stream.i \ + $(WRAPPER_ROOT)/ace/TLI_Connector.i \ + CPP-connector.h \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Connector.h \ + $(WRAPPER_ROOT)/ace/Map_Manager.h \ + $(WRAPPER_ROOT)/ace/Map_Manager.cpp \ + $(WRAPPER_ROOT)/ace/Map_Manager.i \ + $(WRAPPER_ROOT)/ace/Svc_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch_Options.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Svc_Handler.cpp \ + $(WRAPPER_ROOT)/ace/Dynamic.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.i \ + $(WRAPPER_ROOT)/ace/Strategies.h \ + $(WRAPPER_ROOT)/ace/Strategies.cpp \ + $(WRAPPER_ROOT)/ace/Connector.i \ + $(WRAPPER_ROOT)/ace/Connector.cpp \ + CPP-connector.cpp +.obj/test_tli_acceptor.o .shobj/test_tli_acceptor.so: test_tli_acceptor.cpp \ + $(WRAPPER_ROOT)/ace/TLI_Acceptor.h \ + $(WRAPPER_ROOT)/ace/TLI.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/TLI.i \ + $(WRAPPER_ROOT)/ace/TLI_Stream.h \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/TLI_Stream.i \ + $(WRAPPER_ROOT)/ace/TLI_Acceptor.i \ + CPP-acceptor.h \ + $(WRAPPER_ROOT)/ace/Acceptor.h \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch_Options.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Svc_Handler.cpp \ + $(WRAPPER_ROOT)/ace/Dynamic.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.i \ + $(WRAPPER_ROOT)/ace/Strategies.h \ + $(WRAPPER_ROOT)/ace/Strategies.cpp \ + $(WRAPPER_ROOT)/ace/Acceptor.i \ + $(WRAPPER_ROOT)/ace/Acceptor.cpp \ + CPP-acceptor.cpp +.obj/test_spipe_connector.o .shobj/test_spipe_connector.so: test_spipe_connector.cpp \ + $(WRAPPER_ROOT)/ace/SPIPE_Connector.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/SPIPE.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/SPIPE.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Connector.i \ + CPP-connector.h \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Connector.h \ + $(WRAPPER_ROOT)/ace/Map_Manager.h \ + $(WRAPPER_ROOT)/ace/Map_Manager.cpp \ + $(WRAPPER_ROOT)/ace/Map_Manager.i \ + $(WRAPPER_ROOT)/ace/Svc_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch_Options.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Svc_Handler.cpp \ + $(WRAPPER_ROOT)/ace/Dynamic.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.i \ + $(WRAPPER_ROOT)/ace/Strategies.h \ + $(WRAPPER_ROOT)/ace/Strategies.cpp \ + $(WRAPPER_ROOT)/ace/Connector.i \ + $(WRAPPER_ROOT)/ace/Connector.cpp \ + CPP-connector.cpp +.obj/test_spipe_acceptor.o .shobj/test_spipe_acceptor.so: test_spipe_acceptor.cpp \ + $(WRAPPER_ROOT)/ace/SPIPE_Acceptor.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/SPIPE.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/SPIPE.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.i \ + CPP-acceptor.h \ + $(WRAPPER_ROOT)/ace/Acceptor.h \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch_Options.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Svc_Handler.cpp \ + $(WRAPPER_ROOT)/ace/Dynamic.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.i \ + $(WRAPPER_ROOT)/ace/Strategies.h \ + $(WRAPPER_ROOT)/ace/Strategies.cpp \ + $(WRAPPER_ROOT)/ace/Acceptor.i \ + $(WRAPPER_ROOT)/ace/Acceptor.cpp \ + CPP-acceptor.cpp + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/Connection/non_blocking/README b/examples/Connection/non_blocking/README new file mode 100644 index 00000000000..78fb023b99e --- /dev/null +++ b/examples/Connection/non_blocking/README @@ -0,0 +1,24 @@ +This code illustrates how to write a single set of source code (for a +client and server) and then parameterize in the desired IPC mechanism. +In this case, the IPC mechanisms include sockets, TLI, and STREAM +pipes. The single set of source code is located in CPP-acceptor.cpp +(which is the server) and CPP-connector.cpp (which is the non-blocking +client). + +Here's how I typically run these tests: + +% test_sock_acceptor localhost:10005 & +starting up daemon ./test_sock_acceptor +starting server addr 127.0.0.1:10007 on handle 5 +client addr 127.0.0.1:10003 on handle 6 +hello + +% test_sock_connector localhost:10005 +starting up daemon ./test_sock_connector +activating 5 +in handle_output +please enter input..: hello +in handle_output + +There are a number of other options that you can provide. Please see +the source code for details. diff --git a/examples/Connection/non_blocking/test_sock_acceptor.cpp b/examples/Connection/non_blocking/test_sock_acceptor.cpp new file mode 100644 index 00000000000..c723f292aa7 --- /dev/null +++ b/examples/Connection/non_blocking/test_sock_acceptor.cpp @@ -0,0 +1,25 @@ +// ACE_SOCK Server. +// @(#)test_sock_acceptor.cpp 1.1 10/18/96 + + +#include "ace/SOCK_Acceptor.h" +#include "ace/INET_Addr.h" +#include "CPP-acceptor.h" + +typedef Svc_Handler<ACE_SOCK_STREAM> SVC_HANDLER; +typedef IPC_Server<SVC_HANDLER, ACE_SOCK_ACCEPTOR> IPC_SERVER; + +int +main (int argc, char *argv[]) +{ + // Perform Service_Config initializations + ACE_Service_Config daemon (argv[0]); + + IPC_SERVER acceptor; + + if (acceptor.init (argc, argv) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "init"), -1); + + return acceptor.svc (); +} + diff --git a/examples/Connection/non_blocking/test_sock_connector.cpp b/examples/Connection/non_blocking/test_sock_connector.cpp new file mode 100644 index 00000000000..5cfbef12f77 --- /dev/null +++ b/examples/Connection/non_blocking/test_sock_connector.cpp @@ -0,0 +1,25 @@ +// ACE_SOCK Client. +// @(#)test_sock_connector.cpp 1.1 10/18/96 + + +#include "ace/SOCK_Connector.h" +#include "ace/INET_Addr.h" +#include "CPP-connector.h" + +typedef Peer_Handler<ACE_SOCK_STREAM> PEER_HANDLER; +typedef IPC_Client<PEER_HANDLER, ACE_SOCK_CONNECTOR> IPC_CLIENT; + +int +main (int argc, char *argv[]) +{ + // Perform Service_Config initializations + ACE_Service_Config daemon (argv[0]); + + IPC_CLIENT peer_connector; + + if (peer_connector.init (argc, argv) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "init"), -1); + + return peer_connector.svc (); +} + diff --git a/examples/Connection/non_blocking/test_spipe_acceptor.cpp b/examples/Connection/non_blocking/test_spipe_acceptor.cpp new file mode 100644 index 00000000000..a65658634e2 --- /dev/null +++ b/examples/Connection/non_blocking/test_spipe_acceptor.cpp @@ -0,0 +1,25 @@ +// ACE_SPIPE Server. +// @(#)test_spipe_acceptor.cpp 1.1 10/18/96 + + +#include "ace/SPIPE_Acceptor.h" +#include "ace/SPIPE_Addr.h" +#include "CPP-acceptor.h" + +typedef Svc_Handler<ACE_SPIPE_STREAM> SVC_HANDLER; +typedef IPC_Server<SVC_HANDLER, ACE_SPIPE_ACCEPTOR> IPC_SERVER; + +int +main (int argc, char *argv[]) +{ + // Perform Service_Config initializations + ACE_Service_Config daemon (argv[0]); + + IPC_SERVER acceptor; + + if (acceptor.init (argc, argv) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "init"), -1); + + return acceptor.svc (); +} + diff --git a/examples/Connection/non_blocking/test_spipe_connector.cpp b/examples/Connection/non_blocking/test_spipe_connector.cpp new file mode 100644 index 00000000000..ad5b4b3cb1e --- /dev/null +++ b/examples/Connection/non_blocking/test_spipe_connector.cpp @@ -0,0 +1,25 @@ +// ACE_SPIPE Client. +// @(#)test_spipe_connector.cpp 1.1 10/18/96 + + +#include "ace/SPIPE_Connector.h" +#include "ace/SPIPE_Addr.h" +#include "CPP-connector.h" + +typedef Peer_Handler<ACE_SPIPE_STREAM> PEER_HANDLER; +typedef IPC_Client<PEER_HANDLER, ACE_SPIPE_CONNECTOR> IPC_CLIENT; + +int +main (int argc, char *argv[]) +{ + // Perform Service_Config initializations + ACE_Service_Config daemon (argv[0]); + + IPC_CLIENT peer_connector; + + if (peer_connector.init (argc, argv) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "init"), -1); + + return peer_connector.svc (); +} + diff --git a/examples/Connection/non_blocking/test_tli_acceptor.cpp b/examples/Connection/non_blocking/test_tli_acceptor.cpp new file mode 100644 index 00000000000..dccb6305573 --- /dev/null +++ b/examples/Connection/non_blocking/test_tli_acceptor.cpp @@ -0,0 +1,33 @@ +// ACE_TLI Server. +// @(#)test_tli_acceptor.cpp 1.1 10/18/96 + + +#include "ace/TLI_Acceptor.h" +#include "ace/INET_Addr.h" +#include "CPP-acceptor.h" + +#if defined (ACE_HAS_TLI) +typedef Svc_Handler<ACE_TLI_STREAM> SVC_HANDLER; +typedef IPC_Server<SVC_HANDLER, ACE_TLI_ACCEPTOR> IPC_SERVER; + +int +main (int argc, char *argv[]) +{ + // Perform Service_Config initializations + ACE_Service_Config daemon (argv[0]); + + IPC_SERVER acceptor; + + if (acceptor.init (argc, argv) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "init"), -1); + + return acceptor.svc (); +} +#else +int +main (void) +{ + ACE_ERROR_RETURN ((LM_ERROR, "your platform does not support TLI\n"), 1); +} +#endif /* ACE_HAS_TLI */ + diff --git a/examples/Connection/non_blocking/test_tli_connector.cpp b/examples/Connection/non_blocking/test_tli_connector.cpp new file mode 100644 index 00000000000..e3409efca3a --- /dev/null +++ b/examples/Connection/non_blocking/test_tli_connector.cpp @@ -0,0 +1,33 @@ +// ACE_TLI Client. +// @(#)test_tli_connector.cpp 1.1 10/18/96 + + +#include "ace/TLI_Connector.h" +#include "ace/INET_Addr.h" +#include "CPP-connector.h" + +#if defined (ACE_HAS_TLI) + +typedef Peer_Handler<ACE_TLI_STREAM> PEER_HANDLER; +typedef IPC_Client<PEER_HANDLER, ACE_TLI_CONNECTOR> IPC_CLIENT; + +int +main (int argc, char *argv[]) +{ + // Perform Service_Config initializations + ACE_Service_Config daemon (argv[0]); + + IPC_CLIENT peer_connector; + + if (peer_connector.init (argc, argv) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "init"), -1); + + return peer_connector.svc (); +} +#else +int +main (void) +{ + ACE_ERROR_RETURN ((LM_ERROR, "your platform does not support TLI\n"), 1); +} +#endif /* ACE_HAS_TLI */ diff --git a/examples/IPC_SAP/DEV_SAP/Makefile b/examples/IPC_SAP/DEV_SAP/Makefile new file mode 100644 index 00000000000..d596bd3d53c --- /dev/null +++ b/examples/IPC_SAP/DEV_SAP/Makefile @@ -0,0 +1,22 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the DEV_SAP test directory +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +DIRS = reader \ + writer + +#---------------------------------------------------------------------------- +# macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nolocal.GNU diff --git a/examples/IPC_SAP/DEV_SAP/README b/examples/IPC_SAP/DEV_SAP/README new file mode 100644 index 00000000000..8e47d8c5cec --- /dev/null +++ b/examples/IPC_SAP/DEV_SAP/README @@ -0,0 +1,23 @@ +This directory contains a test example for the DEV_SAP +class category. It implements a class TTY_IO that is +derived from ACE_DEV_IO and adds a control method +with specific features for a serial line connection +(e.g. /dev/ttya and /dev/ttyb on UNIX systems). + +The reader/reader executable initializes its +device-special file (given as command-line parameter), +reads characters from it (until it recognizes character 'q') +ands sends the characters read to stdout. + +The writer/writer executable also initializes its +device-special file (given as command-line parameter), +reads characters from stdin (until'q') and sends them +to the device. + +To run the tests I connect /dev/ttya and /dev/ttyb (with a +zero modem cable) and start the reader with "reader /dev/ttya" +and the writer (in a different window) with "writer /dev/ttyb". + +Characters typed in the writer window should now appear as output +in the reader window. Note that characters are buffered till EOL. + diff --git a/examples/IPC_SAP/DEV_SAP/reader/Makefile b/examples/IPC_SAP/DEV_SAP/reader/Makefile new file mode 100644 index 00000000000..12373f002d5 --- /dev/null +++ b/examples/IPC_SAP/DEV_SAP/reader/Makefile @@ -0,0 +1,71 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the simple DEV reader test file +# for serial devices +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = reader + +SRC = $(addsuffix .cpp,$(BIN)) +OBJ = $(SRC:%.cpp=$(VDIR)%.o) + +LSRC = $(addsuffix .cpp,$(FILES)) +LOBJ = $(addsuffix .o,$(FILES)) +SHOBJ = $(addsuffix .so,$(FILES)) + +LIBS = -lACE + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/reader.o .shobj/reader.so: reader.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/DEV_Addr.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/DEV_Connector.h \ + $(WRAPPER_ROOT)/ace/DEV_IO.h \ + $(WRAPPER_ROOT)/ace/DEV.h \ + $(WRAPPER_ROOT)/ace/IO_SAP.h \ + $(WRAPPER_ROOT)/ace/IO_SAP.i \ + $(WRAPPER_ROOT)/ace/DEV.i \ + $(WRAPPER_ROOT)/ace/DEV_IO.i \ + $(WRAPPER_ROOT)/ace/DEV_Connector.i \ + $(WRAPPER_ROOT)/ace/TTY_IO.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/IPC_SAP/DEV_SAP/reader/reader.cpp b/examples/IPC_SAP/DEV_SAP/reader/reader.cpp new file mode 100644 index 00000000000..e4ac8f03123 --- /dev/null +++ b/examples/IPC_SAP/DEV_SAP/reader/reader.cpp @@ -0,0 +1,49 @@ +#include "ace/Log_Msg.h" +// @(#)reader.cpp 1.1 10/18/96 + +#include "ace/OS.h" +#include "ace/DEV_Addr.h" +#include "ace/DEV_Connector.h" +#include "ace/DEV_IO.h" +#include "ace/TTY_IO.h" + +int +main (int argc, char *argv[]) +{ + if (argc < 2) + ACE_ERROR_RETURN ((LM_ERROR, "usage: %s device-filename\n", argv[0]), 1); + + ACE_TTY_IO read_dev; + ACE_DEV_Connector con; + + if (con.connect (read_dev, ACE_DEV_Addr (argv[1])) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", argv[1]), 1); + + ACE_TTY_IO::Serial_Params myparams; + myparams.baudrate = 9600; + myparams.parityenb = 1; + myparams.paritymode = "EVEN"; + myparams.databits = 8; + myparams.stopbits = 1; + myparams.readtimeoutmsec = 10000; + myparams.ctsenb = 0; + myparams.rcvenb = 1; + + int ret = read_dev.control (ACE_TTY_IO::SETPARAMS, &myparams); + + if (ret == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p control\n", argv[1]), 1); + + // Read till character 'q'. + for (char readback = 'x'; readback != 'q'; ) + { + ssize_t bytes_read = read_dev.recv_n ((void *) &readback, 1); + + if (bytes_read == 1) + ACE_DEBUG ((LM_DEBUG, "read: %c\n", readback)); + else if (bytes_read == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p recv\n", argv[1]), 1); + } + + return 0; +} diff --git a/examples/IPC_SAP/DEV_SAP/writer/Makefile b/examples/IPC_SAP/DEV_SAP/writer/Makefile new file mode 100644 index 00000000000..dfa8198f829 --- /dev/null +++ b/examples/IPC_SAP/DEV_SAP/writer/Makefile @@ -0,0 +1,71 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the simple DEV writer test file +# for serial devices +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = writer + +SRC = $(addsuffix .cpp,$(BIN)) +OBJ = $(SRC:%.cpp=$(VDIR)%.o) + +LSRC = $(addsuffix .cpp,$(FILES)) +LOBJ = $(addsuffix .o,$(FILES)) +SHOBJ = $(addsuffix .so,$(FILES)) + +LIBS = -lACE + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/writer.o .shobj/writer.so: writer.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/DEV_Addr.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/DEV_Connector.h \ + $(WRAPPER_ROOT)/ace/DEV_IO.h \ + $(WRAPPER_ROOT)/ace/DEV.h \ + $(WRAPPER_ROOT)/ace/IO_SAP.h \ + $(WRAPPER_ROOT)/ace/IO_SAP.i \ + $(WRAPPER_ROOT)/ace/DEV.i \ + $(WRAPPER_ROOT)/ace/DEV_IO.i \ + $(WRAPPER_ROOT)/ace/DEV_Connector.i \ + $(WRAPPER_ROOT)/ace/TTY_IO.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/IPC_SAP/DEV_SAP/writer/writer.cpp b/examples/IPC_SAP/DEV_SAP/writer/writer.cpp new file mode 100644 index 00000000000..97bd26dd1f6 --- /dev/null +++ b/examples/IPC_SAP/DEV_SAP/writer/writer.cpp @@ -0,0 +1,54 @@ +#include "ace/Log_Msg.h" +// @(#)writer.cpp 1.1 10/18/96 + +#include "ace/DEV_Connector.h" +#include "ace/TTY_IO.h" + +int +main (int argc, char *argv[]) +{ + if (argc < 2) + ACE_ERROR_RETURN ((LM_ERROR, "usage: %s device-filename\n", argv[0]), 1); + + ACE_TTY_IO write_dev; + + ACE_DEV_Connector con; + + if (con.connect (write_dev, ACE_DEV_Addr (argv[1])) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", argv[1]), 1); + + ACE_TTY_IO::Serial_Params myparams; + myparams.baudrate = 9600; + myparams.parityenb = 1; + myparams.paritymode = "EVEN"; + myparams.databits = 8; + myparams.stopbits = 1; + myparams.readtimeoutmsec = 200; + myparams.ctsenb = 0; + myparams.rcvenb = 1; + + int ret = write_dev.control (ACE_TTY_IO::SETPARAMS, &myparams); + + if (ret == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "control"), 1); + + ACE_DEBUG ((LM_DEBUG, "enter character to send, q terminates :\n")); + + for (char writeto = 'x'; + ACE_OS::read (ACE_STDIN, &writeto, 1) != -1; + ) + { + ssize_t bytes_written = write_dev.send_n ((void *)&writeto, 1); + + if (bytes_written != 1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send"), 1); + + if (writeto == 'q') + break; + } + + if (write_dev.close () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), 1); + + return 0; +} diff --git a/examples/IPC_SAP/FIFO_SAP/FIFO-Msg-client.cpp b/examples/IPC_SAP/FIFO_SAP/FIFO-Msg-client.cpp new file mode 100644 index 00000000000..21fcc849de4 --- /dev/null +++ b/examples/IPC_SAP/FIFO_SAP/FIFO-Msg-client.cpp @@ -0,0 +1,36 @@ +#include "ace/FIFO_Send_Msg.h" +// @(#)FIFO-Msg-client.cpp 1.1 10/18/96 + + +#if defined (ACE_HAS_STREAM_PIPES) + +int +main (int, char *[]) +{ + ACE_FIFO_Send_Msg client (ACE_DEFAULT_RENDEZVOUS); + + char buf[BUFSIZ]; + ACE_Str_Buf msg (buf); + + ACE_OS::srand (unsigned (ACE_OS::time (0))); + + while (ACE_OS::fgets (buf, sizeof buf, stdin) != 0) + { + msg.len = strlen (buf) + 1; + if (client.send (ACE_OS::rand () % 11, &msg) == -1) + ::perror ("send"); + } + + if (client.close () == -1) + ACE_OS::perror ("close"), ACE_OS::exit (1); + + return 0; +} +#else +#include <stdio.h> +int main (void) +{ + ACE_OS::fprintf (stderr, "This feature is not supported\n"); + return 0; +} +#endif /* ACE_HAS_STREAM_PIPES */ diff --git a/examples/IPC_SAP/FIFO_SAP/FIFO-Msg-server.cpp b/examples/IPC_SAP/FIFO_SAP/FIFO-Msg-server.cpp new file mode 100644 index 00000000000..f5d50040f81 --- /dev/null +++ b/examples/IPC_SAP/FIFO_SAP/FIFO-Msg-server.cpp @@ -0,0 +1,40 @@ +#include "ace/FIFO_Recv_Msg.h" +// @(#)FIFO-Msg-server.cpp 1.1 10/18/96 + + +#if defined (ACE_HAS_STREAM_PIPES) + +int +main (int, char *[]) +{ + ACE_OS::unlink (ACE_DEFAULT_RENDEZVOUS); + ACE_FIFO_Recv_Msg server (ACE_DEFAULT_RENDEZVOUS); + char buf[BUFSIZ]; + ACE_Str_Buf msg (buf, 0, sizeof buf); + int flags = MSG_ANY; + int band = 0; + int n; + + while ((n = server.recv (&band, &msg, (ACE_Str_Buf *) 0, &flags)) >= 0) + { + if (msg.len == 0) + break; + else + printf ("%4d (%4d): %*s", msg.len, band, msg.len, msg.buf); + flags = MSG_ANY; + band = 0; + } + + if (n == -1) + ACE_OS::perror ("recv"), ACE_OS::exit (1); + + return 0; +} +#else +#include <stdio.h> +int main (void) +{ + ACE_OS::fprintf (stderr, "This feature is not supported\n"); + return 0; +} +#endif /* ACE_HAS_STREAM_PIPES */ diff --git a/examples/IPC_SAP/FIFO_SAP/FIFO-client.cpp b/examples/IPC_SAP/FIFO_SAP/FIFO-client.cpp new file mode 100644 index 00000000000..231c7ebac7e --- /dev/null +++ b/examples/IPC_SAP/FIFO_SAP/FIFO-client.cpp @@ -0,0 +1,24 @@ +#include "ace/Log_Msg.h" +// @(#)FIFO-client.cpp 1.1 10/18/96 + +#include "ace/FIFO_Send.h" + +int +main (int, char *[]) +{ + ACE_FIFO_Send client (ACE_DEFAULT_RENDEZVOUS); + char buf[BUFSIZ]; + + while (ACE_OS::fgets (buf, sizeof buf, stdin) != 0) + { + size_t n = ACE_OS::strlen (buf); + + if (client.send (buf, n) != n) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send"), 1); + } + + if (client.close () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), 1); + + return 0; +} diff --git a/examples/IPC_SAP/FIFO_SAP/FIFO-server.cpp b/examples/IPC_SAP/FIFO_SAP/FIFO-server.cpp new file mode 100644 index 00000000000..9140b9681fa --- /dev/null +++ b/examples/IPC_SAP/FIFO_SAP/FIFO-server.cpp @@ -0,0 +1,25 @@ +#include "ace/Log_Msg.h" +// @(#)FIFO-server.cpp 1.1 10/18/96 + +#include "ace/FIFO_Recv.h" + +int +main (int, char *[]) +{ + ACE_OS::unlink (ACE_DEFAULT_RENDEZVOUS); + ACE_FIFO_Recv server (ACE_DEFAULT_RENDEZVOUS); + char buf[BUFSIZ]; + int n; + + while ((n = server.recv (buf, sizeof buf)) > 0) + { + ACE_OS::printf ("%4d: ", n); + ACE_OS::fflush (stdout); + ACE_OS::write (ACE_STDOUT, buf, n); + } + + if (n == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "recv"), 1); + + return 0; +} diff --git a/examples/IPC_SAP/FIFO_SAP/FIFO-test.cpp b/examples/IPC_SAP/FIFO_SAP/FIFO-test.cpp new file mode 100644 index 00000000000..f191f2abe6e --- /dev/null +++ b/examples/IPC_SAP/FIFO_SAP/FIFO-test.cpp @@ -0,0 +1,92 @@ +/* Purpose: This program uses ACE_FIFO wrappers to perform interprocess +// @(#)FIFO-test.cpp 1.1 10/18/96 + + 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" +#include "ace/FIFO_Send.h" + +#define PERMS 0666 +#define EXEC_NAME "more" +#define EXEC_COMMAND_ARG "more" + +const char *FIFO_NAME = "/tmp/fifo"; + +int +do_child (ACE_FIFO_Recv &fifo_reader) +{ + /* 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; + + char *argv[2]; + argv[0] = EXEC_COMMAND_ARG; + argv[1] = 0; + + if (ACE_OS::execvp (EXEC_NAME, argv) == -1) + return -1; +} + +int +do_parent (const char fifo_name[], char input_filename[]) +{ + int inputfd; + ACE_FIFO_Send fifo_sender (fifo_name, O_WRONLY | O_CREAT); + int len; + char buf[BUFSIZ]; + + if (fifo_sender.get_handle () == ACE_INVALID_HANDLE) + return -1; + + if ((inputfd = ACE_OS::open (input_filename, O_RDONLY)) == -1) + return -1; + + /* 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) + return -1; + + if (len == -1) + return -1; + + if (fifo_sender.remove () == -1) + return -1; + return 0; +} + +int +main (int argc, char *argv[]) +{ + ACE_LOG_MSG->open (argv[0]); + + if (argc != 2) + ACE_ERROR ((LM_ERROR, "usage: %n input-file\n%a", 1)); + + ACE_FIFO_Recv fifo_reader (FIFO_NAME, O_RDONLY | O_CREAT, PERMS, 0); + + if (fifo_reader.get_handle () == ACE_INVALID_HANDLE) + return -1; + + pid_t child_pid; + + switch (child_pid = ACE_OS::fork ()) + { + case -1: + ACE_ERROR ((LM_ERROR, "%n: %p\n%a", "fork", 1)); + case 0: + if (do_child (fifo_reader) == -1) + ACE_ERROR ((LM_ERROR, "%n: %p\n%a", "do_child", 1)); + default: + 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 */ + ACE_ERROR ((LM_ERROR, "%n: %p\n%a", "waitpid", 1)); + } + + return 0; +} diff --git a/examples/IPC_SAP/FIFO_SAP/Makefile b/examples/IPC_SAP/FIFO_SAP/Makefile new file mode 100644 index 00000000000..9ee2b323493 --- /dev/null +++ b/examples/IPC_SAP/FIFO_SAP/Makefile @@ -0,0 +1,132 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for simple FIFO test +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = FIFO-Msg-client \ + FIFO-Msg-server \ + FIFO-client \ + FIFO-server \ + FIFO-test + +LSRC = $(addsuffix .cpp,$(BIN)) + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/FIFO-Msg-client.o .shobj/FIFO-Msg-client.so: FIFO-Msg-client.cpp \ + $(WRAPPER_ROOT)/ace/FIFO_Send_Msg.h \ + $(WRAPPER_ROOT)/ace/FIFO_Send.h \ + $(WRAPPER_ROOT)/ace/FIFO.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/FIFO_Send.i \ + $(WRAPPER_ROOT)/ace/FIFO_Send_Msg.i +.obj/FIFO-Msg-server.o .shobj/FIFO-Msg-server.so: FIFO-Msg-server.cpp \ + $(WRAPPER_ROOT)/ace/FIFO_Recv_Msg.h \ + $(WRAPPER_ROOT)/ace/FIFO_Recv.h \ + $(WRAPPER_ROOT)/ace/FIFO.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/FIFO_Recv.i \ + $(WRAPPER_ROOT)/ace/FIFO_Recv_Msg.i +.obj/FIFO-client.o .shobj/FIFO-client.so: FIFO-client.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/FIFO_Send.h \ + $(WRAPPER_ROOT)/ace/FIFO.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/FIFO_Send.i +.obj/FIFO-server.o .shobj/FIFO-server.so: FIFO-server.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/FIFO_Recv.h \ + $(WRAPPER_ROOT)/ace/FIFO.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/FIFO_Recv.i +.obj/FIFO-test.o .shobj/FIFO-test.so: FIFO-test.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/FIFO_Recv.h \ + $(WRAPPER_ROOT)/ace/FIFO.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/FIFO_Recv.i \ + $(WRAPPER_ROOT)/ace/FIFO_Send.h \ + $(WRAPPER_ROOT)/ace/FIFO_Send.i + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/IPC_SAP/FILE_SAP/Makefile b/examples/IPC_SAP/FILE_SAP/Makefile new file mode 100644 index 00000000000..cf0a6764be7 --- /dev/null +++ b/examples/IPC_SAP/FILE_SAP/Makefile @@ -0,0 +1,62 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the simple file test +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = client + +LSRC = $(addsuffix .cpp,$(BIN)) + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/client.o .shobj/client.so: client.cpp \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/FILE_Addr.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/FILE_Connector.h \ + $(WRAPPER_ROOT)/ace/FILE_IO.h \ + $(WRAPPER_ROOT)/ace/FILE.h \ + $(WRAPPER_ROOT)/ace/IO_SAP.h \ + $(WRAPPER_ROOT)/ace/IO_SAP.i \ + $(WRAPPER_ROOT)/ace/FILE.i \ + $(WRAPPER_ROOT)/ace/FILE_IO.i \ + $(WRAPPER_ROOT)/ace/FILE_Connector.i + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/IPC_SAP/FILE_SAP/client.cpp b/examples/IPC_SAP/FILE_SAP/client.cpp new file mode 100644 index 00000000000..ba8edaf4827 --- /dev/null +++ b/examples/IPC_SAP/FILE_SAP/client.cpp @@ -0,0 +1,57 @@ +#include "ace/OS.h" +// @(#)client.cpp 1.1 10/18/96 + +#include "ace/Log_Msg.h" +#include "ace/FILE_Addr.h" +#include "ace/FILE_Connector.h" +#include "ace/FILE_IO.h" + +int +main (int argc, char *argv[]) +{ + if (argc < 2) + ACE_ERROR_RETURN ((LM_ERROR, "usage: %s filename string\n", argv[0]), 1); + + char *readback = new char[::strlen (argv[1]) + 1]; + + ACE_FILE_Info fileinfo; + ACE_FILE_IO cli_file; + ACE_FILE_Connector con; + + if (con.connect (cli_file, ACE_FILE_Addr (argv[1]), + 0, ACE_Addr::sap_any, 0, + O_RDWR|O_APPEND|O_CREAT, 0666) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n to %s", "connect", argv[1]), -1); + + size_t len = ACE_OS::strlen (argv[2]) + 1; + + if (cli_file.send (argv[2], len) != len) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send"), 1); + + if (cli_file.get_info (&fileinfo) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "get_info"), 1); + else + cout << "fileinfo : mode = " << (fileinfo.mode_ & 777) + << "\nno of links = " << fileinfo.nlink_ + << "\nsize = " << fileinfo.size_ << endl; + + off_t fpos = cli_file.position (); + + if (fpos == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "position"), 1); + else + cout << "current filepointer is at " << fpos << endl; + + if (cli_file.position (0, SEEK_SET) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "position"), 1); + + if (cli_file.recv (readback, len) != len) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "recv"), 1); + + cout << "read back :" << readback << endl; + + if (cli_file.close () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), 1); + + return 0; +} diff --git a/examples/IPC_SAP/FILE_SAP/testfile b/examples/IPC_SAP/FILE_SAP/testfile new file mode 100644 index 00000000000..e7cbb71a0d5 --- /dev/null +++ b/examples/IPC_SAP/FILE_SAP/testfile @@ -0,0 +1 @@ +testfile
\ No newline at end of file diff --git a/examples/IPC_SAP/Makefile b/examples/IPC_SAP/Makefile new file mode 100644 index 00000000000..8414b8c6201 --- /dev/null +++ b/examples/IPC_SAP/Makefile @@ -0,0 +1,27 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the IPC_SAP test directory +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +DIRS = DEV_SAP \ + FIFO_SAP \ + FILE_SAP \ + SOCK_SAP \ + SPIPE_SAP \ + TLI_SAP \ + UPIPE_SAP + +#---------------------------------------------------------------------------- +# macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nolocal.GNU diff --git a/examples/IPC_SAP/SOCK_SAP/C-inclient.cpp b/examples/IPC_SAP/SOCK_SAP/C-inclient.cpp new file mode 100644 index 00000000000..1555e3b8059 --- /dev/null +++ b/examples/IPC_SAP/SOCK_SAP/C-inclient.cpp @@ -0,0 +1,60 @@ +#include "ace/OS.h" +// @(#)C-inclient.cpp 1.1 10/18/96 + + +/* BSD socket client */ + +int +main (int argc, char *argv[]) +{ + // Initialize WinSock DLL on Win32... + ACE_OS::socket_init (ACE_WSOCK_VERSION); + + struct sockaddr_in saddr; + struct hostent *hp; + char *host = argc > 1 ? argv[1] : ACE_DEFAULT_SERVER_HOST; + u_short port_num = + htons (argc > 2 ? atoi (argv[2]) : ACE_DEFAULT_SERVER_PORT); + char buf[BUFSIZ]; + ACE_HANDLE s_handle; + int w_bytes; + int r_bytes; + int n; + + /* Create a local endpoint of communication */ + if ((s_handle = ACE_OS::socket (PF_INET, SOCK_STREAM, 0)) == ACE_INVALID_HANDLE) + ACE_OS::perror ("socket"), ACE_OS::exit (1); + + /* Determine IP address of the server */ + if ((hp = ACE_OS::gethostbyname (host)) == 0) + ACE_OS::perror ("gethostbyname"), ACE_OS::exit (1); + + /* Set up the address information to contact the server */ + ACE_OS::memset ((void *) &saddr, 0, sizeof saddr); + saddr.sin_family = AF_INET; + saddr.sin_port = port_num; + ACE_OS::memcpy (&saddr.sin_addr, hp->h_addr, hp->h_length); + + /* Establish connection with remote server */ + if (ACE_OS::connect (s_handle, (struct sockaddr *) &saddr, + sizeof saddr) == -1) + ACE_OS::perror ("connect"), ACE_OS::exit (1); + + /* Send data to server (correctly handles + "incomplete writes" due to flow control) */ + + while ((r_bytes = ACE_OS::read (ACE_STDIN, buf, sizeof buf)) > 0) + for (w_bytes = 0; w_bytes < r_bytes; w_bytes += n) + if ((n = ACE_OS::send (s_handle, buf + w_bytes, + r_bytes - w_bytes)) < 0) + ACE_OS::perror ("write"), ACE_OS::exit (1); + + if (ACE_OS::recv (s_handle, buf, 1) == 1) + ACE_OS::write (ACE_STDOUT, buf, 1); + + /* Explicitly close the connection */ + if (ACE_OS::closesocket (s_handle) == -1) + ACE_OS::perror ("close"), ACE_OS::exit (1); + + return 0; +} diff --git a/examples/IPC_SAP/SOCK_SAP/C-inserver.cpp b/examples/IPC_SAP/SOCK_SAP/C-inserver.cpp new file mode 100644 index 00000000000..1d35f654a45 --- /dev/null +++ b/examples/IPC_SAP/SOCK_SAP/C-inserver.cpp @@ -0,0 +1,84 @@ +#include "ace/OS.h" +// @(#)C-inserver.cpp 1.1 10/18/96 + + +/* BSD socket server. */ + +int main (int argc, char *argv[]) +{ + // Initialize WinSock DLL on Win32... + ACE_OS::socket_init (ACE_WSOCK_VERSION); + + u_short port_num = + htons (argc > 1 ? ACE_OS::atoi (argv[1]) : ACE_DEFAULT_SERVER_PORT); + struct sockaddr_in saddr; + ACE_HANDLE s_handle, n_handle; + + /* Create a local endpoint of communication */ + if ((s_handle = ACE_OS::socket (PF_INET, SOCK_STREAM, 0)) == ACE_INVALID_HANDLE) + ACE_OS::perror ("socket"), ACE_OS::exit (1); + + /* Set up the address information to become a server */ + ACE_OS::memset ((void *) &saddr, 0, sizeof saddr); + saddr.sin_family = AF_INET; + saddr.sin_port = port_num; + saddr.sin_addr.s_addr = INADDR_ANY; + + /* Associate address with endpoint */ + if (ACE_OS::bind (s_handle, (struct sockaddr *) &saddr, + sizeof saddr) == -1) + ACE_OS::perror ("bind"), ACE_OS::exit (1); + + /* Make endpoint listen for service requests */ + if (ACE_OS::listen (s_handle, 5) == -1) + ACE_OS::perror ("listen"), ACE_OS::exit (1); + + /* Performs the iterative server activities */ + + for (;;) + { + char buf[BUFSIZ]; + int r_bytes; + struct sockaddr_in cli_addr; + int cli_addr_len = sizeof cli_addr; + struct hostent *hp; + + /* Create a new endpoint of communication */ + do + n_handle = ACE_OS::accept (s_handle, (struct sockaddr *) + &cli_addr, &cli_addr_len); + while (n_handle == ACE_INVALID_HANDLE && errno == EINTR); + + if (n_handle == ACE_INVALID_HANDLE) + { + ACE_OS::perror ("accept"); + continue; + } + + int addr_len = sizeof cli_addr.sin_addr.s_addr; + hp = ACE_OS::gethostbyaddr ((char *) &cli_addr.sin_addr, + addr_len, AF_INET); + + if (hp != 0) + ACE_OS::printf ("client %s\n", hp->h_name), ACE_OS::fflush (stdout); + else + ACE_OS::perror ("gethostbyaddr"); + + /* Read data from client (terminate on error) */ + + while ((r_bytes = ACE_OS::recv (n_handle, buf, sizeof buf)) > 0) + if (ACE_OS::write (ACE_STDOUT, buf, r_bytes) != r_bytes) + ACE_OS::perror ("write"), ACE_OS::exit (1); + + if (ACE_OS::send (n_handle, "", 1) != 1) + ::perror ("write"), ACE_OS::exit (1); + + /* Close the new endpoint + (listening endpoint remains open) */ + if (ACE_OS::closesocket (n_handle) == -1) + ACE_OS::perror ("close"), ACE_OS::exit (1); + ACE_OS::exit (0); + } + /* NOTREACHED */ + return 0; +} diff --git a/examples/IPC_SAP/SOCK_SAP/CPP-inclient.cpp b/examples/IPC_SAP/SOCK_SAP/CPP-inclient.cpp new file mode 100644 index 00000000000..249d345fb38 --- /dev/null +++ b/examples/IPC_SAP/SOCK_SAP/CPP-inclient.cpp @@ -0,0 +1,73 @@ +// This tests the non-blocking features of the ACE_SOCK_Connector class. +// @(#)CPP-inclient.cpp 1.1 10/18/96 + + +#include "ace/Log_Msg.h" +#include "ace/SOCK_Connector.h" +#include "ace/INET_Addr.h" + +// ACE SOCK_SAP client. + +int main (int argc, char *argv[]) +{ + char *host = argc > 1 ? argv[1] : ACE_DEFAULT_SERVER_HOST; + u_short r_port = argc > 2 ? ACE_OS::atoi (argv[2]) : ACE_DEFAULT_SERVER_PORT; + int timeout = argc > 3 ? ACE_OS::atoi (argv[3]) : ACE_DEFAULT_TIMEOUT; + u_short l_port = argc > 4 ? ACE_OS::atoi (argv[4]) : ACE_DEFAULT_LOCAL_PORT; + char buf[BUFSIZ]; + + ACE_SOCK_Stream cli_stream; + ACE_INET_Addr remote_addr (r_port, host); + ACE_INET_Addr local_addr (l_port); + + ACE_DEBUG ((LM_DEBUG, "starting non-blocking connect\n")); + // Initiate timed, non-blocking connection with server. + ACE_SOCK_Connector con; + + // Attempt a non-blocking connect to the server, reusing the local + // addr if necessary. + if (con.connect (cli_stream, remote_addr, + (ACE_Time_Value *) &ACE_Time_Value::zero, + local_addr, 1) == -1) + { + if (errno != EWOULDBLOCK) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "connection failed"), 1); + + ACE_DEBUG ((LM_DEBUG, "starting timed connect\n")); + + // Check if non-blocking connection is in progress, + // and wait up to timeout seconds for it to complete. + ACE_Time_Value tv (timeout); + + if (con.complete (cli_stream, &remote_addr, &tv) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "connection failed"), 1); + else + ACE_DEBUG ((LM_DEBUG, "connected to %s\n", remote_addr.get_host_name ())); + } + + if (cli_stream.disable (ACE_NONBLOCK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "disable"), 1); + + // Send data to server (correctly handles "incomplete writes"). + + for (ssize_t r_bytes; + (r_bytes = ACE_OS::read (ACE_STDIN, buf, sizeof buf)) > 0; ) + if (ACE_OS::strcmp (buf, "quit\n") == 0) + break; + else if (cli_stream.send_n (buf, r_bytes) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send_n"), 1); + + // Explicitly close the writer-side of the connection. + if (cli_stream.close_writer () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close_writer"), 1); + + // Wait for handshake with server. + if (cli_stream.recv_n (buf, 1) != 1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "recv_n"), 1); + + // Close the connection completely. + if (cli_stream.close () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), 1); + + return 0; +} diff --git a/examples/IPC_SAP/SOCK_SAP/CPP-inserver-poll.cpp b/examples/IPC_SAP/SOCK_SAP/CPP-inserver-poll.cpp new file mode 100644 index 00000000000..ccd164be11a --- /dev/null +++ b/examples/IPC_SAP/SOCK_SAP/CPP-inserver-poll.cpp @@ -0,0 +1,101 @@ +// IPC_SAP/poll server, which illustrates how to integrate the ACE +// @(#)CPP-inserver-poll.cpp 1.1 10/18/96 + +// socket wrappers with the SVR4 poll() system call to create a +// single-threaded concurrent server. + +#include "ace/SOCK_Acceptor.h" +#include "ace/SOCK_Stream.h" +#include "ace/INET_Addr.h" + +#if defined (ACE_HAS_SVR4_POLL) + +// Maximum per-process open I/O descriptors. +const int MAX_FDS = 200; + +int +main (void) +{ + // Create a server end-point. + ACE_INET_Addr addr (ACE_DEFAULT_SERVER_PORT); + ACE_SOCK_Acceptor peer_acceptor (addr); + ACE_SOCK_Stream new_stream; + ACE_HANDLE s_handle = peer_acceptor.get_handle (); + struct pollfd poll_array[MAX_FDS]; + + for (int i = 0; i < MAX_FDS; i++) + { + poll_array[i].fd = ACE::INVALID_HANDLE; + poll_array[i].events = POLLIN; + } + + poll_array[0].fd = s_handle; + + for (int n_handles = 1;;) + { + // Wait for client I/O events (handle interrupts). + while (ACE_OS::poll (poll_array, n_handles) == -1 + && errno == EINTR) + continue; + + // Handle pending logging messages first (s_handle + 1 is + // guaranteed to be lowest client descriptor). + + for (i = 1; i < n_handles; i++) + { + if (poll_array[i].revents & POLLIN) + { + char buf[BUFSIZ]; + int n; + // recv will not block in this case! + if ((n = ACE_OS::recv (poll_array[i].fd, buf, sizeof buf, 0)) == -1) + ACE_OS::perror ("read failed"); + else if (n == 0) + { + // Handle client connection shutdown. + if (ACE_OS::close (poll_array[i].fd) == -1) + ACE_OS::perror ("close"); + poll_array[i].fd = poll_array[--n_handles].fd; + + // Send handshake back to client to unblock it. + if (ACE_OS::send (poll_array[i].fd, "", 1) != 1) + ACE_ERROR ((LM_ERROR, "%p\n", "send_n")); + } + else + ACE_OS::printf ("%*s", n, buf), fflush (stdout); + } + ACE_OS::fflush (stdout); + } + if (poll_array[0].revents & POLLIN) + { + ACE_INET_Addr client; + ACE_Time_Value nonblock (0, 0); + + // Handle all pending connection requests (note use of + // "polling" feature that doesn't block). + + while (ACE_OS::poll (poll_array, 1, nonblock) > 0) + if (peer_acceptor.accept (new_stream, &client) == -1) + ACE_OS::perror ("accept"); + else + { + const char *s = client.get_host_name (); + + ACE_ASSERT (s != 0); + ACE_OS::printf ("client %s\n", s); + ACE_OS::fflush (stdout); + poll_array[n_handles++].fd = new_stream.get_handle (); + } + } + } + /* NOTREACHED */ + return 0; +} +#else +#include <stdio.h> +int main (void) +{ + ACE_OS::fprintf (stderr, "This feature is not supported\n"); + return 0; +} +#endif /* ACE_HAS_SVR4_POLL */ diff --git a/examples/IPC_SAP/SOCK_SAP/CPP-inserver.cpp b/examples/IPC_SAP/SOCK_SAP/CPP-inserver.cpp new file mode 100644 index 00000000000..fefeb39fdeb --- /dev/null +++ b/examples/IPC_SAP/SOCK_SAP/CPP-inserver.cpp @@ -0,0 +1,136 @@ +// This example tests the non-blocking features of the +// @(#)CPP-inserver.cpp 1.1 10/18/96 + +// ACE_SOCK_Acceptor and ACE_SOCK_Stream classes. + +#include "ace/Log_Msg.h" +#include "ace/SOCK_Acceptor.h" +#include "ace/SOCK_Stream.h" +#include "ace/INET_Addr.h" +#include "ace/Handle_Set.h" + +// ACE SOCK_SAP server. + +int +main (int argc, char *argv[]) +{ + u_short port = argc > 1 + ? ACE_OS::atoi (argv[1]) + : ACE_DEFAULT_SERVER_PORT; + ACE_Time_Value timeout (argc > 2 + ? ACE_OS::atoi (argv[2]) + : ACE_DEFAULT_TIMEOUT); + + ACE_SOCK_Acceptor peer_acceptor; + + // Create a server address. + ACE_INET_Addr server_addr (port); + + // Create a server, reuse the address. + if (peer_acceptor.open (server_addr, 1) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), 1); + // Set the peer acceptor into non-blocking mode. + else if (peer_acceptor.enable (ACE_NONBLOCK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "enable"), 1); + else if (peer_acceptor.get_local_addr (server_addr) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "get_local_addr"), 1); + + ACE_DEBUG ((LM_DEBUG, "starting server at port %d\n", + server_addr.get_port_number ())); + + // Keep these objects out here to prevent excessive constructor + // calls within the loop. + ACE_SOCK_Stream new_stream; + ACE_INET_Addr cli_addr; + ACE_Handle_Set handle_set; + + // Performs the iterative server activities. + + for (;;) + { + char buf[BUFSIZ]; + + handle_set.reset (); + handle_set.set_bit (peer_acceptor.get_handle ()); + + int result = ACE_OS::select (int (peer_acceptor.get_handle ()) + 1, + handle_set, + 0, 0, &timeout); + if (result == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "select"), -1); + else if (result == 0) + ACE_DEBUG ((LM_DEBUG, "select timed out\n")); + else + { + // Create a new ACE_SOCK_Stream endpoint (note automatic restart + // if errno == EINTR). + + while ((result = peer_acceptor.accept (new_stream, &cli_addr)) != -1) + { + ACE_DEBUG ((LM_DEBUG, "client %s connected from %d\n", + cli_addr.get_host_name (), cli_addr.get_port_number ())); + + // Enable non-blocking I/O. + if (new_stream.enable (ACE_NONBLOCK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "enable"), -1); + + handle_set.reset (); + handle_set.set_bit (new_stream.get_handle ()); + + // Read data from client (terminate on error). + + for (ssize_t r_bytes;;) + { + if (ACE_OS::select (int (new_stream.get_handle ()) + 1, + handle_set, + 0, 0, 0) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "select"), -1); + + for (;;) + { + r_bytes = new_stream.recv (buf, sizeof buf); + + if (r_bytes <= 0) + break; + else if (ACE::write_n (ACE_STDOUT, buf, r_bytes) != r_bytes) + ACE_ERROR ((LM_ERROR, "%p\n", "ACE::send_n")); + } + + if (r_bytes == 0) + { + ACE_DEBUG ((LM_DEBUG, + "reached end of input, connection closed by client\n")); + + // Send handshake back to client to unblock it. + if (new_stream.send_n ("", 1) != 1) + ACE_ERROR ((LM_ERROR, "%p\n", "send_n")); + break; + } + else if (r_bytes == -1) + { + if (errno == EWOULDBLOCK) + ACE_DEBUG ((LM_DEBUG, + "no input available, going back to reading\n")); + else + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "recv"), -1); + } + } + + // Close new endpoint (listening endpoint stays open). + if (new_stream.close () == -1) + ACE_ERROR ((LM_ERROR, "%p\n", "close")); + } + + if (result == -1) + { + if (errno == EWOULDBLOCK) + ACE_DEBUG ((LM_DEBUG, + "no connections available, going back to accepting\n")); + else + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE::write"), -1); + } + } + } + /* NOTREACHED */ + return 0; +} diff --git a/examples/IPC_SAP/SOCK_SAP/CPP-unclient.cpp b/examples/IPC_SAP/SOCK_SAP/CPP-unclient.cpp new file mode 100644 index 00000000000..abd3ad87a50 --- /dev/null +++ b/examples/IPC_SAP/SOCK_SAP/CPP-unclient.cpp @@ -0,0 +1,50 @@ +/* ACE_LSOCK Client */ +// @(#)CPP-unclient.cpp 1.1 10/18/96 + + +#include "ace/Log_Msg.h" +#include "ace/LSOCK_Connector.h" +#include "ace/UNIX_Addr.h" + +#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) + +int +main (int argc, char *argv[]) +{ + char *rendezvous = argc > 1 ? argv[1] : ACE_DEFAULT_RENDEZVOUS; + char buf[BUFSIZ]; + + ACE_LSOCK_Stream cli_stream; + ACE_LSOCK_Connector con; + + /* Establish the connection with server */ + if (con.connect (cli_stream, ACE_UNIX_Addr (rendezvous)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "connect"), 1); + + /* Send data to server (correctly handles "incomplete writes") */ + + for (int r_bytes; (r_bytes = ACE_OS::read (ACE_STDIN, buf, sizeof buf)) > 0; ) + if (cli_stream.send_n (buf, r_bytes) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send_n"), 1); + + /* Explicitly close the writer-side of the connection. */ + if (cli_stream.close_writer () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close_writer"), 1); + + /* Wait for handshake with server. */ + if (cli_stream.recv_n (buf, 1) != 1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "recv_n"), 1); + + /* Close the connection completely. */ + if (cli_stream.close () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), 1); + + return 0; +} +#else +int main (void) +{ + ACE_ERROR_RETURN ((LM_ERROR, + "this platform does not support UNIX-domain sockets\n"), -1); +} +#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */ diff --git a/examples/IPC_SAP/SOCK_SAP/CPP-unserver.cpp b/examples/IPC_SAP/SOCK_SAP/CPP-unserver.cpp new file mode 100644 index 00000000000..d1455090e76 --- /dev/null +++ b/examples/IPC_SAP/SOCK_SAP/CPP-unserver.cpp @@ -0,0 +1,78 @@ +/* ACE_LSOCK Server */ +// @(#)CPP-unserver.cpp 1.1 10/18/96 + + +#include "ace/Log_Msg.h" +#include "ace/LSOCK_Acceptor.h" +#include "ace/LSOCK_Stream.h" +#include "ace/UNIX_Addr.h" + +#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) + +int +main (int argc, char *argv[]) +{ + char *rendezvous = argc > 1 ? argv[1] : ACE_DEFAULT_RENDEZVOUS; + + /* Create a server address. */ + ACE_UNIX_Addr server_addr (rendezvous); + + ACE_LSOCK_Acceptor peer_acceptor; + + /* Create a server */ + + if (peer_acceptor.open (server_addr) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), 1); + + /* Keep these guys out here to prevent excessive constructor + calls... */ + ACE_LSOCK_Stream new_stream; + ACE_UNIX_Addr cli_addr; + + ACE_DEBUG ((LM_DEBUG, "starting server %s\n", + server_addr.get_path_name ())); + + /* Performs the iterative server activities */ + + for (;;) + { + char buf[BUFSIZ]; + ACE_Time_Value timeout (ACE_DEFAULT_TIMEOUT); + + /* Create a new ACE_SOCK_Stream endpoint (note + automatic restart if errno == EINTR) */ + + if (peer_acceptor.accept (new_stream, &cli_addr, &timeout) == -1) + { + ACE_ERROR ((LM_ERROR, "%p\n", "accept")); + continue; + } + + ACE_DEBUG ((LM_DEBUG, "client %s\n", + cli_addr.get_path_name ())); + + /* Read data from client (terminate on error) */ + + for (int r_bytes; + (r_bytes = new_stream.recv (buf, sizeof buf)) > 0; ) + if (ACE_OS::write (ACE_STDOUT, buf, r_bytes) != r_bytes) + ACE_ERROR ((LM_ERROR, "%p\n", "ACE::send_n")); + + if (new_stream.send_n ("", 1) != 1) + ACE_ERROR ((LM_ERROR, "%p\n", "send_n")); + + /* Close new endpoint (listening endpoint stays open) */ + if (new_stream.close () == -1) + ACE_ERROR ((LM_ERROR, "%p\n", "close")); + } + + /* NOTREACHED */ + return 0; +} +#else +int main (void) +{ + ACE_ERROR_RETURN ((LM_ERROR, + "this platform does not support UNIX-domain sockets\n"), -1); +} +#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */ diff --git a/examples/IPC_SAP/SOCK_SAP/FD-unclient.cpp b/examples/IPC_SAP/SOCK_SAP/FD-unclient.cpp new file mode 100644 index 00000000000..ed026d9e53c --- /dev/null +++ b/examples/IPC_SAP/SOCK_SAP/FD-unclient.cpp @@ -0,0 +1,51 @@ +#include "ace/LSOCK_Connector.h" +// @(#)FD-unclient.cpp 1.1 10/18/96 + +#include "ace/UNIX_Addr.h" + +#if defined (ACE_HAS_MSG) && !defined (ACE_HAS_UNIX_DOMAIN_SOCKETS) +// ACE_LSOCK Client. + +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; + int n; + char buf[BUFSIZ]; + + ACE_LSOCK_Stream cli_stream; + ACE_UNIX_Addr addr (rendezvous); + + /* 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) + ACE_OS::perror ("open"), ACE_OS::exit (1); + + /* Send data to server (correctly handles incomplete writes) */ + if (cli_stream.send_handle (fd) == -1) + ACE_OS::perror ("send"), ACE_OS::exit (1); + + if ((n = cli_stream.recv_n (buf, sizeof buf)) == -1) + ACE_OS::perror ("recv"), ACE_OS::exit (1); + else + ACE_OS::write (ACE_STDOUT, buf, n); + + /* Explicitly close the connection */ + if (cli_stream.close () == -1) + ACE_OS::perror ("close"), ACE_OS::exit (1); + + return 0; +} +#else +int main (void) +{ + ACE_ERROR_RETURN ((LM_ERROR, "your platform must support sendmsg/recvmsg to run this test\n"), -1); +} +#endif /* ACE_HAS_MSG */ diff --git a/examples/IPC_SAP/SOCK_SAP/FD-unserver.cpp b/examples/IPC_SAP/SOCK_SAP/FD-unserver.cpp new file mode 100644 index 00000000000..4d988ba9253 --- /dev/null +++ b/examples/IPC_SAP/SOCK_SAP/FD-unserver.cpp @@ -0,0 +1,60 @@ +#include "ace/LSOCK_Acceptor.h" +// @(#)FD-unserver.cpp 1.1 10/18/96 + +#include "ace/LSOCK_Stream.h" +#include "ace/UNIX_Addr.h" + +#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) + +/* ACE_SOCK Server */ + +int +main (int argc, char *argv[]) +{ + char *rendezvous = argc > 1 ? argv[1] : ACE_DEFAULT_RENDEZVOUS; + /* 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 */ + + for (;;) + { + char buf[BUFSIZ]; + int fd; + + /* 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) */ + + if (new_stream.recv_handle (fd) == -1) + ::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); + + ACE_OS::puts ("----------------------------------------"); + + if (new_stream.send ("yow", 3) == -1) + ::perror ("send"), ACE_OS::exit (1); + + /* Close new endpoint (listening endpoint stays open) */ + if (new_stream.close () == -1) + ACE_OS::perror ("close"); + } + /* NOTREACHED */ + return 0; +} +#else +int +main (void) +{ + ACE_ERROR_RETURN ((LM_ERROR, "your platform doesn't not support UNIX domain sockets\n"), -1); +} +#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */ diff --git a/examples/IPC_SAP/SOCK_SAP/Makefile b/examples/IPC_SAP/SOCK_SAP/Makefile new file mode 100644 index 00000000000..604ff0da614 --- /dev/null +++ b/examples/IPC_SAP/SOCK_SAP/Makefile @@ -0,0 +1,246 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for IPC_SAP test +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +INFO = README + +BIN = CPP-inclient \ + CPP-unclient \ + CPP-inserver \ + CPP-inserver-poll \ + CPP-unserver \ + FD-unclient \ + FD-unserver \ + C-inclient \ + C-inserver + +LSRC = $(addsuffix .cpp,$(BIN)) + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/CPP-inclient.o .shobj/CPP-inclient.so: CPP-inclient.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/SOCK_Connector.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/SOCK_Connector.i +.obj/CPP-unclient.o .shobj/CPP-unclient.so: CPP-unclient.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/LSOCK_Connector.h \ + $(WRAPPER_ROOT)/ace/SOCK_Connector.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/SOCK_Connector.i \ + $(WRAPPER_ROOT)/ace/LSOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/LSOCK.h \ + $(WRAPPER_ROOT)/ace/LSOCK.i \ + $(WRAPPER_ROOT)/ace/LSOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/UNIX_Addr.h \ + $(WRAPPER_ROOT)/ace/LSOCK_Connector.i +.obj/CPP-inserver.o .shobj/CPP-inserver.so: CPP-inserver.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/SOCK_Acceptor.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Handle_Set.h +.obj/CPP-inserver-poll.o .shobj/CPP-inserver-poll.so: CPP-inserver-poll.cpp \ + $(WRAPPER_ROOT)/ace/SOCK_Acceptor.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i +.obj/CPP-unserver.o .shobj/CPP-unserver.so: CPP-unserver.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/LSOCK_Acceptor.h \ + $(WRAPPER_ROOT)/ace/SOCK_Acceptor.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/UNIX_Addr.h \ + $(WRAPPER_ROOT)/ace/LSOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/LSOCK.h \ + $(WRAPPER_ROOT)/ace/LSOCK.i \ + $(WRAPPER_ROOT)/ace/LSOCK_Stream.i +.obj/FD-unclient.o .shobj/FD-unclient.so: FD-unclient.cpp \ + $(WRAPPER_ROOT)/ace/LSOCK_Connector.h \ + $(WRAPPER_ROOT)/ace/SOCK_Connector.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/SOCK_Connector.i \ + $(WRAPPER_ROOT)/ace/LSOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/LSOCK.h \ + $(WRAPPER_ROOT)/ace/LSOCK.i \ + $(WRAPPER_ROOT)/ace/LSOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/UNIX_Addr.h \ + $(WRAPPER_ROOT)/ace/LSOCK_Connector.i +.obj/FD-unserver.o .shobj/FD-unserver.so: FD-unserver.cpp \ + $(WRAPPER_ROOT)/ace/LSOCK_Acceptor.h \ + $(WRAPPER_ROOT)/ace/SOCK_Acceptor.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/UNIX_Addr.h \ + $(WRAPPER_ROOT)/ace/LSOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/LSOCK.h \ + $(WRAPPER_ROOT)/ace/LSOCK.i \ + $(WRAPPER_ROOT)/ace/LSOCK_Stream.i +.obj/C-inclient.o .shobj/C-inclient.so: C-inclient.cpp \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h +.obj/C-inserver.o .shobj/C-inserver.so: C-inserver.cpp \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/IPC_SAP/SOCK_SAP/README b/examples/IPC_SAP/SOCK_SAP/README new file mode 100644 index 00000000000..3155575ddb1 --- /dev/null +++ b/examples/IPC_SAP/SOCK_SAP/README @@ -0,0 +1,35 @@ +This directory contains groups of client and server test programs that +exercise the various C++ wrappers for sockets. In general, the test +programs do more or less the same thing -- they transfer data from +client to the server. Unless noted differently, the server is +implemented as an "iterative server," i.e., it only deals with one +client at a time. The following describes each set of tests in more +detail: + + . C-inclient.cpp/C-inserver.cpp -- This is basically a C code + implementation that opens a connection to the server and + sends all the data from the stdin using Internet domain + sockets (i.e., TCP). + + . CPP-inclient.cpp/CPP-server.cpp -- This test is basically + a C++ wrapper version of the preceeding "C" test using + Internet domain sockets (i.e., TCP). + + . CPP-unclient.cpp/CPP-unserver.cpp -- This test is basically + a C++ wrapper version of the preceeding "C++" test using + UNIX domain sockets. + + . FD-unclient.cpp/FD-inclient.cpp -- This test illustrates + how to pass file descriptors between two processes on the + same machine using the ACE C++ wrappers for UNIX domain + sockets. + + . CPP-inserver-poll.cpp -- This test illustrates how to + write single-threaded concurrent servers using UNIX SVR4 + poll(). You can run this test using the CPP-inclient.cpp + program as the client. + +For examples of the ACE SOCK_{Dgram,CODgram} and +SOCK_Dgram_{Mcast,Bcast} wrappers, please take a look in the +./examples/Reactor/{Dgram,Multicast,Ntalker} directories. + diff --git a/examples/IPC_SAP/SOCK_SAP/local_data b/examples/IPC_SAP/SOCK_SAP/local_data new file mode 100644 index 00000000000..c0119859a28 --- /dev/null +++ b/examples/IPC_SAP/SOCK_SAP/local_data @@ -0,0 +1 @@ +I am Iron man! diff --git a/examples/IPC_SAP/SPIPE_SAP/Makefile b/examples/IPC_SAP/SPIPE_SAP/Makefile new file mode 100644 index 00000000000..10d79cb2a7a --- /dev/null +++ b/examples/IPC_SAP/SPIPE_SAP/Makefile @@ -0,0 +1,218 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the simple STREAM pipe client/server test file +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = client \ + server \ + consumer_msg \ + consumer_read \ + producer_msg \ + producer_read \ + NPClient \ + NPServer + +LSRC = $(addsuffix .cpp,$(BIN)) + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/client.o .shobj/client.so: client.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Connector.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/SPIPE.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SPIPE.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Connector.i \ + shared.h +.obj/server.o .shobj/server.so: server.cpp \ + $(WRAPPER_ROOT)/ace/SPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Acceptor.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/SPIPE.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SPIPE.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.i \ + shared.h +.obj/consumer_msg.o .shobj/consumer_msg.so: consumer_msg.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Acceptor.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/SPIPE.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SPIPE.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.i \ + shared.h +.obj/consumer_read.o .shobj/consumer_read.so: consumer_read.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Acceptor.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/SPIPE.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SPIPE.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.i \ + shared.h +.obj/producer_msg.o .shobj/producer_msg.so: producer_msg.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Connector.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/SPIPE.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SPIPE.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Connector.i \ + shared.h +.obj/producer_read.o .shobj/producer_read.so: producer_read.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Connector.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/SPIPE.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SPIPE.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Connector.i \ + shared.h +.obj/NPClient.o .shobj/NPClient.so: NPClient.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Connector.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/SPIPE.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SPIPE.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Connector.i +.obj/NPServer.o .shobj/NPServer.so: NPServer.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Acceptor.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/SPIPE.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SPIPE.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.i + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/IPC_SAP/SPIPE_SAP/NPClient.cpp b/examples/IPC_SAP/SPIPE_SAP/NPClient.cpp new file mode 100644 index 00000000000..552d462367b --- /dev/null +++ b/examples/IPC_SAP/SPIPE_SAP/NPClient.cpp @@ -0,0 +1,46 @@ +#include "ace/Log_Msg.h" +// @(#)NPClient.cpp 1.1 10/18/96 + +#include "ace/SPIPE_Addr.h" +#include "ace/SPIPE_Connector.h" + +#if defined (ACE_WIN32) +#define MAKE_PIPE_NAME(X) \\\\.\\pipe\\#X +#else +#define MAKE_PIPE_NAME(X) X +#endif + +const int DEFAULT_SIZE = 8; +const int DEFAULT_COUNT = 10000; + +int +main (int argc, char *argv[]) +{ + int size = argc > 1 ? atoi (argv[1]) : DEFAULT_SIZE; + int iterations = argc > 2 ? atoi (argv[2]) : DEFAULT_COUNT; + char *buf = new char[size]; + + //char *pipe_name = ACE_DEFAULT_RENDEZVOUS; + char *pipe_name = "acepipe"; + char *rendezvous; + rendezvous = MAKE_PIPE_NAME (pipe_name); + + ACE_SPIPE_Stream cli_stream; + ACE_SPIPE_Connector con; + int i; + + if (con.connect (cli_stream, ACE_SPIPE_Addr (rendezvous)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", rendezvous), -1); + + ACE_OS::strcpy (buf, "hello"); + size = ACE_OS::strlen (buf) + 1; + + for (i = 0; i < iterations; i++) + if (cli_stream.send (buf, size) != size) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "putmsg"), -1); + + if (cli_stream.close () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), -1); + + return 0; +} diff --git a/examples/IPC_SAP/SPIPE_SAP/NPServer.cpp b/examples/IPC_SAP/SPIPE_SAP/NPServer.cpp new file mode 100644 index 00000000000..eb4be9451a7 --- /dev/null +++ b/examples/IPC_SAP/SPIPE_SAP/NPServer.cpp @@ -0,0 +1,54 @@ +#include "ace/Log_Msg.h" +// @(#)NPServer.cpp 1.1 10/18/96 + +#include "ace/SPIPE_Addr.h" +#include "ace/Time_Value.h" +#include "ace/SPIPE_Acceptor.h" + +#if defined (ACE_WIN32) +#define MAKE_PIPE_NAME(X) \\\\.\\pipe\\#X +#else +#define MAKE_PIPE_NAME(X) X +#endif + +int +main (int argc, char *argv[]) +{ + ACE_SPIPE_Acceptor acceptor; + ACE_SPIPE_Stream new_stream; + char buf[BUFSIZ]; + int n; + // char *pipe_name = ACE_DEFAULT_RENDEZVOUS; + char *pipe_name = "acepipe"; + + char *rendezvous; + rendezvous = MAKE_PIPE_NAME (pipe_name); + + /* Initialize named pipe listener */ + + if (acceptor.open (ACE_SPIPE_Addr (rendezvous)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), 1); + + for (;;) + { + ACE_DEBUG ((LM_DEBUG, "waiting for connection\n")); + + /* Accept a client connection */ + if (acceptor.accept (new_stream, 0) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "accept"), 1); + + ACE_DEBUG ((LM_DEBUG, "Accepted connection\n")); + + while ((n = new_stream.recv (buf, sizeof buf)) > 0) + { + cerr << buf << endl; + ACE_OS::write (ACE_STDOUT, buf, n); + } + if (n == -1) + { + ACE_DEBUG ((LM_DEBUG, "End of connection. Closing handle\n")); + new_stream.close (); + } + } + return 0; +} diff --git a/examples/IPC_SAP/SPIPE_SAP/client.cpp b/examples/IPC_SAP/SPIPE_SAP/client.cpp new file mode 100644 index 00000000000..8c0b6e0a074 --- /dev/null +++ b/examples/IPC_SAP/SPIPE_SAP/client.cpp @@ -0,0 +1,42 @@ +#include "ace/Log_Msg.h" +// @(#)client.cpp 1.1 10/18/96 + +#include "ace/SPIPE_Addr.h" +#include "ace/SPIPE_Connector.h" +#include "shared.h" + +#if defined (ACE_HAS_STREAM_PIPES) + +int +main (int argc, char *argv[]) +{ + if (argc < 2) + ACE_ERROR_RETURN ((LM_ERROR, "usage: %s string [rendezvous]\n", argv[0]), 1); + + if (argc > 2) + rendezvous = argv[2]; + + ACE_SPIPE_Stream cli_stream; + ACE_SPIPE_Connector con; + + if (con.connect (cli_stream, ACE_SPIPE_Addr (rendezvous)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", rendezvous), 1); + + size_t len = ACE_OS::strlen (argv[1]) + 1; + + if (cli_stream.send (argv[1], len) != len) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send"), 1); + + if (cli_stream.close () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), 1); + + return 0; +} +#else +#include <stdio.h> +int main (void) +{ + ACE_OS::fprintf (stderr, "This feature is not supported\n"); + return 0; +} +#endif /* ACE_HAS_STREAM_PIPES */ diff --git a/examples/IPC_SAP/SPIPE_SAP/consumer_msg.cpp b/examples/IPC_SAP/SPIPE_SAP/consumer_msg.cpp new file mode 100644 index 00000000000..ad96c04677b --- /dev/null +++ b/examples/IPC_SAP/SPIPE_SAP/consumer_msg.cpp @@ -0,0 +1,53 @@ +#include "ace/Log_Msg.h" +// @(#)consumer_msg.cpp 1.1 10/18/96 + +#include "ace/SPIPE_Addr.h" +#include "ace/SPIPE_Acceptor.h" +#include "ace/Time_Value.h" +#include "shared.h" + +#if defined (ACE_HAS_STREAM_PIPES) + +int +main (int argc, char *argv[]) +{ + ACE_SPIPE_Acceptor peer_acceptor; + ACE_SPIPE_Stream new_stream; + char buf[BUFSIZ]; + ACE_Str_Buf buffer (buf, 0, sizeof buf); + int flags = 0; + + if (argc > 1) + rendezvous = argv[1]; + + ACE_OS::unlink (rendezvous); + ACE_OS::fdetach (rendezvous); + + ACE_SPIPE_Addr addr (rendezvous); + ACE_Time_Value timeout (ACE_DEFAULT_TIMEOUT); + + if (peer_acceptor.open (addr) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), 1); + + ACE_DEBUG ((LM_DEBUG, "waiting for connection\n")); + + if (peer_acceptor.accept (new_stream, 0, &timeout) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "accept"), 1); + + ACE_DEBUG ((LM_DEBUG, "accepted\n")); + + while (new_stream.recv ((ACE_Str_Buf *) 0, &buffer, &flags) >= 0) + if (buffer.len == 0) + break; + else + ACE_OS::write (ACE_STDOUT, buffer.buf, buffer.len); + return 0; +} +#else +#include <stdio.h> +int main (void) +{ + ACE_OS::fprintf (stderr, "This feature is not supported\n"); + return 0; +} +#endif /* ACE_HAS_STREAM_PIPES */ diff --git a/examples/IPC_SAP/SPIPE_SAP/consumer_read.cpp b/examples/IPC_SAP/SPIPE_SAP/consumer_read.cpp new file mode 100644 index 00000000000..bffa3ff90b8 --- /dev/null +++ b/examples/IPC_SAP/SPIPE_SAP/consumer_read.cpp @@ -0,0 +1,50 @@ +#include "ace/Log_Msg.h" +// @(#)consumer_read.cpp 1.1 10/18/96 + +#include "ace/SPIPE_Addr.h" +#include "ace/SPIPE_Acceptor.h" +#include "ace/Time_Value.h" +#include "shared.h" + +#if defined (ACE_HAS_STREAM_PIPES) + +int +main (int argc, char *argv[]) +{ + ACE_SPIPE_Acceptor peer_acceptor; + ACE_SPIPE_Stream new_stream; + char buf[BUFSIZ]; + int n; + + // Wait up to ACE_DEFAULT_TIMEOUT seconds to accept connection. + ACE_Time_Value timeout (ACE_DEFAULT_TIMEOUT); + + if (argc > 1) + rendezvous = argv[1]; + + ACE_OS::unlink (rendezvous); + ACE_OS::fdetach (rendezvous); + + if (peer_acceptor.open (ACE_SPIPE_Addr (rendezvous)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), 1); + + ACE_DEBUG ((LM_DEBUG, "waiting for connection\n")); + + if (peer_acceptor.accept (new_stream, 0, &timeout) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "accept"), 1); + + ACE_DEBUG ((LM_DEBUG, "accepted\n")); + + while ((n = new_stream.recv (buf, sizeof buf)) > 0) + ACE_OS::write (ACE_STDOUT, buf, n); + + return 0; +} +#else +#include <stdio.h> +int main (void) +{ + ACE_OS::fprintf (stderr, "This feature is not supported\n"); + return 0; +} +#endif /* ACE_HAS_STREAM_PIPES */ diff --git a/examples/IPC_SAP/SPIPE_SAP/producer_msg.cpp b/examples/IPC_SAP/SPIPE_SAP/producer_msg.cpp new file mode 100644 index 00000000000..4109fbe31ca --- /dev/null +++ b/examples/IPC_SAP/SPIPE_SAP/producer_msg.cpp @@ -0,0 +1,52 @@ +#include "ace/Log_Msg.h" +// @(#)producer_msg.cpp 1.1 10/18/96 + +#include "ace/SPIPE_Addr.h" +#include "ace/SPIPE_Connector.h" +#include "shared.h" + +#if defined (ACE_HAS_STREAM_PIPES) + +const int DEFAULT_SIZE = 4 * 1024; +const int DEFAULT_COUNT = 100; + +int +main (int argc, char *argv[]) +{ + int size = argc > 1 ? atoi (argv[1]) : DEFAULT_SIZE; + int iterations = argc > 2 ? atoi (argv[2]) : DEFAULT_COUNT; + char *buf = new char[size]; + + if (argc > 3) + rendezvous = argv[3]; + + ACE_SPIPE_Stream cli_stream; + ACE_SPIPE_Connector con; + int i; + + if (con.connect (cli_stream, ACE_SPIPE_Addr (rendezvous)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", rendezvous), 1); + + for (i = 0; i < size; i++) + buf[i] = 'a'; + + ACE_Str_Buf buffer (buf, size); + + for (i = 0; i < iterations; i++) + if (cli_stream.send ((ACE_Str_Buf *) 0, &buffer) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send"), 1); + + if (cli_stream.close () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), 1); + + delete buf; + return 0; +} +#else +#include <stdio.h> +int main (void) +{ + ACE_OS::fprintf (stderr, "This feature is not supported\n"); + return 0; +} +#endif /* ACE_HAS_STREAM_PIPES */ diff --git a/examples/IPC_SAP/SPIPE_SAP/producer_read.cpp b/examples/IPC_SAP/SPIPE_SAP/producer_read.cpp new file mode 100644 index 00000000000..883b2994110 --- /dev/null +++ b/examples/IPC_SAP/SPIPE_SAP/producer_read.cpp @@ -0,0 +1,49 @@ +#include "ace/Log_Msg.h" +// @(#)producer_read.cpp 1.1 10/18/96 + +#include "ace/SPIPE_Addr.h" +#include "ace/SPIPE_Connector.h" +#include "shared.h" + +#if defined (ACE_HAS_STREAM_PIPES) + +const int DEFAULT_SIZE = 8 * 1024; +const int DEFAULT_COUNT = 100; + +int +main (int argc, char *argv[]) +{ + int size = argc > 1 ? atoi (argv[1]) : DEFAULT_SIZE; + int iterations = argc > 2 ? atoi (argv[2]) : DEFAULT_COUNT; + char *buf = new char[size]; + + if (argc > 3) + rendezvous = argv[3]; + + ACE_SPIPE_Stream cli_stream; + ACE_SPIPE_Connector con; + int i; + + if (con.connect (cli_stream, ACE_SPIPE_Addr (rendezvous)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", rendezvous), -1); + + for (i = 0; i < size; i++) + buf[i] = 'a'; + + for (i = 0; i < iterations; i++) + if (cli_stream.send (buf, size) != size) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "putmsg"), -1); + + if (cli_stream.close () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), -1); + + return 0; +} +#else +#include <stdio.h> +int main (void) +{ + ACE_ERROR_RETURN ((LM_ERROR, "this feature is not supported"), -1); + return 0; +} +#endif /* ACE_HAS_STREAM_PIPES */ diff --git a/examples/IPC_SAP/SPIPE_SAP/server.cpp b/examples/IPC_SAP/SPIPE_SAP/server.cpp new file mode 100644 index 00000000000..3173d6433cf --- /dev/null +++ b/examples/IPC_SAP/SPIPE_SAP/server.cpp @@ -0,0 +1,116 @@ +#include "ace/SPIPE_Addr.h" +// @(#)server.cpp 1.1 10/18/96 + +#include "ace/SPIPE_Acceptor.h" +#include "shared.h" + +#if defined (ACE_HAS_STREAM_PIPES) + +/* Maximum per-process open I/O descriptors */ +const int MAX_FDS = 200; +const int PERMS = 0666; + +int +main (int argc, char *argv[]) +{ + ACE_SPIPE_Acceptor peer_acceptor; + ACE_SPIPE_Stream new_stream; + int s_handle; + struct pollfd poll_array[MAX_FDS]; + + if (argc > 1) + rendezvous = argv[1]; + + ACE_OS::fdetach (rendezvous); + + ACE_SPIPE_Addr addr (rendezvous); + + if ((s_handle = peer_acceptor.open (addr)) == -1) + ACE_OS::perror ("peer_acceptor.open"), ACE_OS::exit (1); + + for (int fd = 0; fd < MAX_FDS; fd++) + { + poll_array[fd].fd = -1; + poll_array[fd].events = POLLIN; + } + + poll_array[0].fd = s_handle; + + for (int width = 1;;) + { + // Block waiting for client I/O events (handle interrupts). + while (ACE_OS::poll (poll_array, width) == -1 && errno == EINTR) + continue; + + /* Handle pending logging messages first (s_handle + 1 + is guaranteed to be lowest client descriptor) */ + + for (int fd = s_handle + 1; fd < width; fd++) + if ((poll_array[fd].revents & POLLIN) + || (poll_array[fd].revents & POLLHUP)) + { + char buf[BUFSIZ]; + int n; + + /* recv will not block in this case! */ + if ((n = ACE_OS::read (fd, buf, sizeof buf)) == -1) + ACE_OS::perror ("read failed"); + else if (n == 0) + { + /* Handle client connection shutdown */ + if (ACE_OS::close (poll_array[fd].fd) == -1) + ACE_OS::perror ("close"); + poll_array[fd].fd = -1; + + if (fd + 1 == width) + { + while (poll_array[fd].fd == -1) + fd--; + width = fd + 1; + } + } + else + { + ::printf ("%*s\n", n, buf); + fflush (stdout); + } + } + + if (poll_array[0].revents & POLLIN) + { + int arg; + int n_handle; + ACE_SPIPE_Addr client; + + if (peer_acceptor.accept (new_stream) == -1) + ACE_OS::perror ("local_accept"); + + n_handle = new_stream.get_handle (); + + if (new_stream.get_remote_addr (client) == -1) + ACE_OS::perror ("get_remote_addr"); + + ACE_OS::printf ("n_handle = %d, uid = %d, gid = %d\n", + n_handle, client.user_id (), client.group_id ()); + + arg = RMSGN | RPROTDAT; + + if (ACE_OS::ioctl (n_handle, I_SRDOPT, (void *) arg) == -1) + ACE_OS::perror ("I_RRDOPT"); + + poll_array[n_handle].fd = n_handle; + if (n_handle >= width) + width = n_handle + 1; + } + } + + return 0; +} +#else +#include <stdio.h> +int main (void) +{ + ACE_OS::fprintf (stderr, "This feature is not supported\n"); + return 0; +} +#endif /* ACE_HAS_STREAM_PIPES */ diff --git a/examples/IPC_SAP/SPIPE_SAP/shared.h b/examples/IPC_SAP/SPIPE_SAP/shared.h new file mode 100644 index 00000000000..13fcf34fac2 --- /dev/null +++ b/examples/IPC_SAP/SPIPE_SAP/shared.h @@ -0,0 +1,6 @@ +/* -*- C++ -*- */ +// @(#)shared.h 1.1 10/18/96 + +#include "ace/OS.h" + +static const char *rendezvous = ACE_DEFAULT_RENDEZVOUS; diff --git a/examples/IPC_SAP/TLI_SAP/CPP-client.cpp b/examples/IPC_SAP/TLI_SAP/CPP-client.cpp new file mode 100644 index 00000000000..8c34dfe866a --- /dev/null +++ b/examples/IPC_SAP/TLI_SAP/CPP-client.cpp @@ -0,0 +1,68 @@ +#include "ace/Log_Msg.h" +// @(#)CPP-client.cpp 1.1 10/18/96 + +#include "ace/TLI_Connector.h" +#include "ace/INET_Addr.h" +#include "ace/Time_Value.h" + +#if defined (ACE_HAS_TLI) + +/* ACE_TLI Client */ + +int main (int argc, char *argv[]) +{ + char *host = argc > 1 ? argv[1] : ACE_DEFAULT_SERVER_HOST; + u_short r_port = argc > 2 ? ACE_OS::atoi (argv[2]) : ACE_DEFAULT_SERVER_PORT; + int timeout = argc > 3 ? ACE_OS::atoi (argv[3]) : ACE_DEFAULT_TIMEOUT; + u_short l_port = argc > 4 ? ACE_OS::atoi (argv[4]) : ACE_DEFAULT_LOCAL_PORT; + char buf[BUFSIZ]; + + ACE_TLI_Stream cli_stream; + ACE_INET_Addr remote_addr (r_port, host); + ACE_INET_Addr local_addr (l_port); + + ACE_DEBUG ((LM_DEBUG, "starting non-blocking connect\n")); + + // Initiate timed, non-blocking connection with server. + ACE_TLI_Connector con; + + if (con.connect (cli_stream, remote_addr, + (ACE_Time_Value *) &ACE_Time_Value::zero, + local_addr, 1) == -1) + { + if (errno != EWOULDBLOCK) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "connection failed"), 1); + + ACE_DEBUG ((LM_DEBUG, "starting timed connect\n")); + + // Check if non-blocking connection is in progress, + // and wait up to timeout seconds for it to complete. + ACE_Time_Value tv (timeout); + + if (con.complete (cli_stream, &remote_addr, &tv) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "connection failed"), 1); + else + ACE_DEBUG ((LM_DEBUG, "connected to %s\n", + remote_addr.get_host_name ())); + } + + // Send data to server (correctly handles "incomplete writes"). + + for (int r_bytes; + (r_bytes = ACE_OS::read (ACE_STDIN, buf, sizeof buf)) > 0; ) + if (cli_stream.send_n (buf, r_bytes) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send_n"), 1); + + /* Explicitly close the connection */ + if (cli_stream.close () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), -1); + + return 0; +} +#else +int main (void) +{ + ACE_ERROR_RETURN ((LM_ERROR, + "your platform must support ACE_TLI\n"), 1); +} +#endif /* ACE_HAS_TLI */ diff --git a/examples/IPC_SAP/TLI_SAP/CPP-server.cpp b/examples/IPC_SAP/TLI_SAP/CPP-server.cpp new file mode 100644 index 00000000000..b0852615b70 --- /dev/null +++ b/examples/IPC_SAP/TLI_SAP/CPP-server.cpp @@ -0,0 +1,68 @@ +#include "ace/Log_Msg.h" +// @(#)CPP-server.cpp 1.1 10/18/96 + +#include "ace/TLI_Acceptor.h" +#include "ace/INET_Addr.h" + +#if defined (ACE_HAS_TLI) +/* ACE_TLI Server */ + +int +main (int argc, char *argv[]) +{ + u_short port = argc > 1 ? ACE_OS::atoi (argv[1]) : ACE_DEFAULT_SERVER_PORT; + ACE_Time_Value timeout (argc > 2 ? ACE_OS::atoi (argv[2]) : ACE_DEFAULT_TIMEOUT); + + /* Create a server address. */ + ACE_INET_Addr addr (port); + + /* Create a server, reuse the addr. */ + ACE_TLI_Acceptor peer_acceptor; + + if (peer_acceptor.open (addr, 1) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); + + ACE_TLI_Stream new_stream; + + ACE_DEBUG ((LM_DEBUG, "starting server at port %d\n", + addr.get_port_number ())); + + /* Performs the iterative server activities */ + + for (;;) + { + char buf[BUFSIZ]; + + /* Create a new ACE_TLI_Stream endpoint (note automatic restart + if errno == EINTR) */ + if (peer_acceptor.accept (new_stream, + &addr, &timeout) == -1) + { + ACE_ERROR ((LM_ERROR, "%p\n", "accept")); + continue; + } + + ACE_DEBUG ((LM_DEBUG, "client %s connected from %d\n", + addr.get_host_name (), addr.get_port_number ())); + + // Read data from client (terminate on error). + + for (int r_bytes; + (r_bytes = new_stream.recv (buf, sizeof buf)) > 0; ) + if (ACE_OS::write (ACE_STDOUT, buf, r_bytes) != r_bytes) + ACE_ERROR ((LM_ERROR, "%p\n", "ACE::send_n")); + + // Close new endpoint (listening endpoint stays open). + if (new_stream.close () == -1) + ACE_ERROR ((LM_ERROR, "%p\n", "close")); + + } + /* NOTREACHED */ + return 0; +} +#else +int main (void) +{ + ACE_ERROR_RETURN ((LM_ERROR, "your platform must support ACE_TLI\n"), 1); +} +#endif /* ACE_HAS_TLI */ diff --git a/examples/IPC_SAP/TLI_SAP/Makefile b/examples/IPC_SAP/TLI_SAP/Makefile new file mode 100644 index 00000000000..ce6a90c2a83 --- /dev/null +++ b/examples/IPC_SAP/TLI_SAP/Makefile @@ -0,0 +1,197 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for TLI_SAP test +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = ftp-client \ + ftp-server \ + db-client \ + db-server \ + CPP-client \ + CPP-server + +LSRC = $(addsuffix .cpp,$(BIN)) + +LDLIBS= + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +INSTALL = + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/ftp-client.o .shobj/ftp-client.so: ftp-client.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/TLI_Connector.h \ + $(WRAPPER_ROOT)/ace/TLI_Stream.h \ + $(WRAPPER_ROOT)/ace/TLI.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/TLI.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/TLI_Stream.i \ + $(WRAPPER_ROOT)/ace/TLI_Connector.i +.obj/ftp-server.o .shobj/ftp-server.so: ftp-server.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/TLI_Acceptor.h \ + $(WRAPPER_ROOT)/ace/TLI.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/TLI.i \ + $(WRAPPER_ROOT)/ace/TLI_Stream.h \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/TLI_Stream.i \ + $(WRAPPER_ROOT)/ace/TLI_Acceptor.i +.obj/db-client.o .shobj/db-client.so: db-client.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/TLI_Connector.h \ + $(WRAPPER_ROOT)/ace/TLI_Stream.h \ + $(WRAPPER_ROOT)/ace/TLI.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/TLI.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/TLI_Stream.i \ + $(WRAPPER_ROOT)/ace/TLI_Connector.i +.obj/db-server.o .shobj/db-server.so: db-server.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/TLI_Acceptor.h \ + $(WRAPPER_ROOT)/ace/TLI.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/TLI.i \ + $(WRAPPER_ROOT)/ace/TLI_Stream.h \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/TLI_Stream.i \ + $(WRAPPER_ROOT)/ace/TLI_Acceptor.i \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i +.obj/CPP-client.o .shobj/CPP-client.so: CPP-client.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/TLI_Connector.h \ + $(WRAPPER_ROOT)/ace/TLI_Stream.h \ + $(WRAPPER_ROOT)/ace/TLI.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/TLI.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/TLI_Stream.i \ + $(WRAPPER_ROOT)/ace/TLI_Connector.i +.obj/CPP-server.o .shobj/CPP-server.so: CPP-server.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/TLI_Acceptor.h \ + $(WRAPPER_ROOT)/ace/TLI.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/TLI.i \ + $(WRAPPER_ROOT)/ace/TLI_Stream.h \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/TLI_Stream.i \ + $(WRAPPER_ROOT)/ace/TLI_Acceptor.i + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/IPC_SAP/TLI_SAP/db-client.cpp b/examples/IPC_SAP/TLI_SAP/db-client.cpp new file mode 100644 index 00000000000..b8396d03705 --- /dev/null +++ b/examples/IPC_SAP/TLI_SAP/db-client.cpp @@ -0,0 +1,52 @@ +#include "ace/Log_Msg.h" +// @(#)db-client.cpp 1.1 10/18/96 + +#include "ace/TLI_Connector.h" + +#if defined (ACE_HAS_TLI) +const int MAXLINE = 255; + +int +main (int argc, char *argv[]) +{ + if (argc < 2) + ACE_ERROR_RETURN ((LM_ERROR, "Usage: %s employee_id [server-host port-number]\n", + argv[0]), -1); + + const char *emp_num = argv[1]; + const char *host_name = argc < 3 ? ACE_DEFAULT_SERVER_HOST : argv[2]; + unsigned short port = argc < 4 ? ACE_DEFAULT_SERVER_PORT : ACE_OS::atoi (argv[3]); + int n; + char buf[MAXLINE]; + + ACE_TLI_Stream client; + ACE_TLI_Connector con; + + if (con.connect (client, ACE_INET_Addr (port, host_name)) == -1) + ACE_OS::t_error ((char *)host_name), ACE_OS::exit (1); + + ACE_OS::strcpy (buf, emp_num); + n = ACE_OS::strlen (buf); + + if (client.send_n (buf, n) != n) + ACE_OS::t_error ("client.send error"); + + if (client.recv (buf, MAXLINE) == -1 && t_errno != TLOOK && client.look () != T_DISCONNECT) + ACE_OS::t_error ("client.recv error"); + + if (ACE_OS::strcmp (buf, "ERROR") == 0) + ACE_OS::printf ("Employee ID %s not in database\n", emp_num); + else + ACE_OS::printf ("Employee name requested is: %s\n", buf); + + if (client.close () == -1) + ACE_OS::t_error ("cli_close"), ACE_OS::exit (1); + + return 0; +} +#else +int main (void) +{ + ACE_ERROR_RETURN ((LM_ERROR, "your platform must support ACE_TLI\n"), 1); +} +#endif /* ACE_HAS_TLI */ diff --git a/examples/IPC_SAP/TLI_SAP/db-server.cpp b/examples/IPC_SAP/TLI_SAP/db-server.cpp new file mode 100644 index 00000000000..ec293242db0 --- /dev/null +++ b/examples/IPC_SAP/TLI_SAP/db-server.cpp @@ -0,0 +1,111 @@ +/* Simple multi-threaded database server example. */ +// @(#)db-server.cpp 1.1 10/18/96 + +#include "ace/Log_Msg.h" +#include "ace/TLI_Acceptor.h" +#include "ace/Thread_Manager.h" + +#if defined (ACE_HAS_THREADS) && defined (ACE_HAS_TLI) + +/* Global thread manager. */ +ACE_Thread_Manager thr_mgr; + +void * +lookup_name (ACE_HANDLE handle) +{ + ACE_Thread_Control tc (&thr_mgr); + + enum + { + MAXLINE = 255, + EMPNAMELEN = 512 + }; + + static struct + { + int emp_id; + const char emp_name[EMPNAMELEN]; + } employee_db[] = + { + {123, "John Wayne Bobbit"}, + {124, "Cindy Crawford"}, + {125, "O. J. Simpson"}, + {126, "Bill Clinton"}, + {127, "Rush Limbaugh"}, + {128, "Michael Jackson"}, + {129, "George Burns"}, + {130, "Paula Jones"}, + {0, ""} + }; + + int n; + int flags; + int len; + int employee_id; + int index; + int found; + ACE_TLI_Stream stream; + char recvline[MAXLINE]; + char sendline[MAXLINE]; + + ACE_DEBUG ((LM_DEBUG, "stream handle = %d, thread id = %t\n", handle)); + stream.set_handle (handle); + + if ((n = stream.recv (recvline, MAXLINE, &flags)) == -1) + ACE_OS::t_error ("stream.recv error"); + + employee_id = ACE_OS::atoi (recvline); + found = 0; + + for (index = 0; found == 0 && employee_db[index].emp_id; index++) + if (employee_id == employee_db[index].emp_id) + { + found = 1; + n = ACE_OS::sprintf (sendline, "%s", employee_db[index].emp_name); + } + + if (found == 0) + n = ACE_OS::sprintf (sendline, "%s", "ERROR"); + + if ((len = stream.send (sendline, n + 1, 0)) == -1) + ACE_OS::t_error ("stream.send error"); + + if (stream.sndrel () == -1) + ACE_OS::t_error ("stream.send error"); + + if (stream.close () == -1) + ACE_OS::t_error ("stream.close error"); + + return 0; +} + +int +main (int argc, char *argv[]) +{ + u_short port = argc > 1 ? ACE_OS::atoi (argv[1]) : ACE_DEFAULT_SERVER_PORT; + ACE_INET_Addr l_addr (port); + ACE_TLI_Acceptor server (l_addr, 1); // Create server, reuse addr if in use. + ACE_TLI_Stream new_stream; + + // Wait for a connection from a client. This is an example of a + // concurrent server. + + for (;;) + { + if (server.accept (new_stream) == -1) + ::t_error ("server.accept error"); + + if (thr_mgr.spawn (ACE_THR_FUNC (lookup_name), + (void *) new_stream.get_handle (), + THR_DETACHED) == -1) + ACE_DEBUG ((LM_ERROR, "server: can't create worker thread %d\n")); + } + return 0; +} +#else +#include <stdio.h> +int main (void) +{ + ACE_ERROR_RETURN ((LM_ERROR, "your platform must support ACE_TLI\n"), 1); +} +#endif /* ACE_HAS_THREADS */ diff --git a/examples/IPC_SAP/TLI_SAP/ftp-client.cpp b/examples/IPC_SAP/TLI_SAP/ftp-client.cpp new file mode 100644 index 00000000000..e664c31c06e --- /dev/null +++ b/examples/IPC_SAP/TLI_SAP/ftp-client.cpp @@ -0,0 +1,45 @@ +#include "ace/Log_Msg.h" +// @(#)ftp-client.cpp 1.1 10/18/96 + +#include "ace/TLI_Connector.h" + +#if defined (ACE_HAS_TLI) + +const int MAXLINE = 255; + +int +main (int argc, char *argv[]) +{ + if (argc < 2) + ACE_OS::fprintf (stderr, "Usage: %s filename [server-host port-number]\n", argv[0]), ACE_OS::exit (1); + + const char *filename = argv[1]; + const char *host_name = argc < 3 ? ACE_DEFAULT_SERVER_HOST : argv[2]; + unsigned short port = argc < 4 ? ACE_DEFAULT_SERVER_PORT : ACE_OS::atoi (argv[3]); + + ACE_TLI_Stream client; + ACE_TLI_Connector con; + int fd; + char buf[BUFSIZ]; + + if (con.connect (client, ACE_INET_Addr (port, host_name)) == -1) + ACE_OS::t_error ((char *) host_name), ACE_OS::exit (1); + + if ((fd = ACE_OS::open (filename, O_RDONLY)) == -1) + ACE_OS::perror (filename), ACE_OS::exit (1); + + for (int n; (n = ACE_OS::read (fd, buf, sizeof buf)) > 0; ) + if (client.send_n (buf, n) != n) + ACE_OS::t_error ("client.send error"); + + if (client.close () == -1) + ACE_OS::t_error ("cli_close"), ACE_OS::exit (1); + + return 0; +} +#else +int main (void) +{ + ACE_ERROR_RETURN ((LM_ERROR, "your platform does not support ACE_TLI\n"), 1); +} +#endif /* ACE_HAS_TLI */ diff --git a/examples/IPC_SAP/TLI_SAP/ftp-server.cpp b/examples/IPC_SAP/TLI_SAP/ftp-server.cpp new file mode 100644 index 00000000000..116af9c2942 --- /dev/null +++ b/examples/IPC_SAP/TLI_SAP/ftp-server.cpp @@ -0,0 +1,75 @@ +/* Simple file transfer example */ +// @(#)ftp-server.cpp 1.1 10/18/96 + +#include "ace/Log_Msg.h" +#include "ace/Thread_Manager.h" +#include "ace/TLI_Acceptor.h" + +#if defined (ACE_HAS_THREADS) && defined (ACE_HAS_TLI) + +ACE_Thread_Manager thr_mgr; + +void * +read_file (void *fd) +{ + ACE_Thread_Control tc (&thr_mgr); + ACE_TLI_Stream stream; + char buf[BUFSIZ]; + int flags = 0; + int n; + + stream.set_handle (int (fd)); + + ACE_OS::printf ("start (tid = %d, fd = %d)\n", ACE_OS::thr_self (), stream.get_handle ()); + ACE_OS::fflush (stdout); + + while ((n = stream.recv (buf, sizeof buf, &flags)) > 0) + continue; + + ACE_OS::printf ("finish (tid = %d, fd = %d)\n", ACE_OS::thr_self (), stream.get_handle ()); + + if (stream.close () == -1) + ACE_OS::t_error ("stream.close error"); + + return 0; +} + +int +main (int argc, char *argv[]) +{ + u_short port = argc > 1 ? ACE_OS::atoi (argv[1]) : ACE_DEFAULT_SERVER_PORT; + ACE_TLI_Acceptor server; + ACE_TLI_Stream new_stream; + + /* Allow up to 100 simultaneous threads */ + if (thr_mgr.open (100) == -1) + ACE_OS::perror ("thr_mgr.open"), ACE_OS::exit (1); + + // Open the server and reuse the address if in use... + if (server.open (ACE_INET_Addr (port), 1) == -1) + ACE_OS::t_error ("server.open"), ACE_OS::exit (1); + + /* Wait for a connection from a client. This is an example of a concurrent server */ + + for (int count = 1; ; count++) + { + ACE_OS::fprintf (stderr, "thread %d, blocking for accept #%d\n", + ACE_OS::thr_self (), count); + + if (server.accept (new_stream) == -1) + ACE_OS::t_error ("server.accept error"); + + else if (thr_mgr.spawn (ACE_THR_FUNC (read_file), + (void *) new_stream.get_handle (), + THR_DETACHED | THR_BOUND) == -1) + ACE_OS::perror ("can't create worker thread\n"); + } + return 0; +} +#else +#include <stdio.h> +int main (void) +{ + ACE_ERROR_RETURN ((LM_ERROR, "your platform must support ACE_TLI\n"), 1); +} +#endif /* ACE_HAS_THREADS */ diff --git a/examples/IPC_SAP/TLI_SAP/signal_thread.c b/examples/IPC_SAP/TLI_SAP/signal_thread.c new file mode 100644 index 00000000000..e3a3485f1a2 --- /dev/null +++ b/examples/IPC_SAP/TLI_SAP/signal_thread.c @@ -0,0 +1,53 @@ +#define _REENTRANT +// @(#)signal_thread.c 1.1 10/18/96 + +#include <stdio.h> +#include <stdlib.h> +#include <signal.h> +#include <thread.h> +#include <synch.h> +#include <unistd.h> + +void *handle (v) + void *v; +{ + sigset_t set; + + sigemptyset (&set); + sigaddset (&set, SIGINT); + + for (;;) + if (sigwait (&set) != SIGINT) + perror ("sigwait"), exit (1); + else + fprintf (stderr, "got sigint!\n"); +} + +int +main (void) +{ + int retval; + sigset_t set; + thread_t t_id; + + sigemptyset (&set); + sigaddset (&set, SIGINT); + + if (sigprocmask (SIG_BLOCK, &set, 0) == -1) + perror ("sigprocmask"), exit (1); + + if (thr_sigsetmask (SIG_BLOCK, &set, 0) == -1) + perror ("sigprocmask"), exit (1); + + if (thr_create (0, 0, handle, 0, THR_DETACHED, &t_id) != 0) + perror ("thr_create"), exit (1); + + for (;;) + { + fprintf (stderr, "blocking for read in thread\n"); + if (read (0, &retval, sizeof retval) != sizeof retval) + perror ("read"); + } + fprintf (stderr, "I'm exiting!\n"); + return 0; +} diff --git a/examples/IPC_SAP/UPIPE_SAP/Makefile b/examples/IPC_SAP/UPIPE_SAP/Makefile new file mode 100644 index 00000000000..ba8ff4b7735 --- /dev/null +++ b/examples/IPC_SAP/UPIPE_SAP/Makefile @@ -0,0 +1,300 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the simple ACE_UPIPE client/server test file +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = ex1 \ + ex2 \ + ex3 + +LSRC = $(addsuffix .cpp,$(BIN)) + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/ex1.o .shobj/ex1.so: ex1.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Stream.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Stream.cpp \ + $(WRAPPER_ROOT)/ace/Stream.i \ + $(WRAPPER_ROOT)/ace/UPIPE_Acceptor.h \ + $(WRAPPER_ROOT)/ace/UPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/SPIPE.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/SPIPE.i \ + $(WRAPPER_ROOT)/ace/UPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Acceptor.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.i \ + $(WRAPPER_ROOT)/ace/UPIPE_Acceptor.i \ + $(WRAPPER_ROOT)/ace/UPIPE_Connector.h \ + $(WRAPPER_ROOT)/ace/UPIPE_Connector.i +.obj/ex2.o .shobj/ex2.so: ex2.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/UPIPE_Connector.h \ + $(WRAPPER_ROOT)/ace/UPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/Stream.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Stream.cpp \ + $(WRAPPER_ROOT)/ace/Stream.i \ + $(WRAPPER_ROOT)/ace/SPIPE.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/SPIPE.i \ + $(WRAPPER_ROOT)/ace/UPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.i \ + $(WRAPPER_ROOT)/ace/UPIPE_Connector.i \ + $(WRAPPER_ROOT)/ace/UPIPE_Acceptor.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Acceptor.h \ + $(WRAPPER_ROOT)/ace/UPIPE_Acceptor.i \ + auto_builtin_ptr.h +.obj/ex3.o .shobj/ex3.so: ex3.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/UPIPE_Connector.h \ + $(WRAPPER_ROOT)/ace/UPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/Stream.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Stream.cpp \ + $(WRAPPER_ROOT)/ace/Stream.i \ + $(WRAPPER_ROOT)/ace/SPIPE.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/SPIPE.i \ + $(WRAPPER_ROOT)/ace/UPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.i \ + $(WRAPPER_ROOT)/ace/UPIPE_Connector.i \ + $(WRAPPER_ROOT)/ace/UPIPE_Acceptor.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Acceptor.h \ + $(WRAPPER_ROOT)/ace/UPIPE_Acceptor.i \ + auto_builtin_ptr.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/IPC_SAP/UPIPE_SAP/auto_builtin_ptr.h b/examples/IPC_SAP/UPIPE_SAP/auto_builtin_ptr.h new file mode 100644 index 00000000000..3dd22c04967 --- /dev/null +++ b/examples/IPC_SAP/UPIPE_SAP/auto_builtin_ptr.h @@ -0,0 +1,20 @@ +/* -*- C++ -*- */ +// @(#)auto_builtin_ptr.h 1.1 10/18/96 + +template <class X> +class auto_builtin_ptr + // = TITLE + // Implements an simple-minded auto_ptr abstraction for builtin types. +{ +public: + // = Initialization and termination methods + auto_builtin_ptr (X *p = 0): p_ (p) {} + ~auto_builtin_ptr (void) { delete [] this->p_; } + + // = Accessor methods. + operator X * (void) const { return this->p_; } + +private: + X *p_; +}; + diff --git a/examples/IPC_SAP/UPIPE_SAP/ex1.cpp b/examples/IPC_SAP/UPIPE_SAP/ex1.cpp new file mode 100644 index 00000000000..8f2246e425b --- /dev/null +++ b/examples/IPC_SAP/UPIPE_SAP/ex1.cpp @@ -0,0 +1,155 @@ +// Example for using ACE_UPIPE_SAP and ACE_Thread for intra-process +// @(#)ex1.cpp 1.1 10/18/96 + +// communication. +// +// Author : Gerhard Lenzer and Douglas C. Schmidt + +#include "ace/Log_Msg.h" +#include "ace/Stream.h" +#include "ace/UPIPE_Acceptor.h" +#include "ace/UPIPE_Connector.h" + +#if defined (ACE_HAS_THREADS) + +// Global thread manager. +static ACE_Thread_Manager thr_mgr; + +//ACE_UPIPE_Manager ltc_mgr; + +// Global pattern +static ACE_UPIPE_Addr addr ("pattern"); + +// peer1 thread. + +static void * +peer1 (void *) +{ + // Insert thread into thr_mgr. + ACE_Thread_Control thread_control (&thr_mgr); + ACE_UPIPE_Stream c_stream; + + ACE_UPIPE_Addr c_addr ("pattern"); + + ACE_DEBUG ((LM_DEBUG, "(%t) peer1 starting connect\n")); + ACE_UPIPE_Connector con; + + if (con.connect (c_stream, addr) == -1) + ACE_DEBUG ((LM_DEBUG, "(%t) peer1 ACE_UPIPE_Connector failed\n")); + + ACE_Message_Block *mb = new ACE_Message_Block (20); + mb->copy ("hello", 6); + + if (c_stream.send (mb) == -1) + ACE_DEBUG ((LM_DEBUG, "(%t) error peer1 send\n")); + + if (c_stream.recv (mb) == -1) + ACE_DEBUG ((LM_DEBUG, "(%t) error peer1 recv\n")); + + ACE_DEBUG ((LM_DEBUG, "(%t) peer1 ack is \"%s\"\n", mb->rd_ptr ())); + + // Free up the memory block. + delete mb; + + // Now try the send()/recv() interface. + char mytext[] = "This string is sent by peer1 as buffer"; + + ACE_DEBUG ((LM_DEBUG, "(%t) peer1 sending text\n")); + if (c_stream.send (mytext, sizeof mytext) == -1) + ACE_DEBUG ((LM_DEBUG, + "(%t) buffer send from peer1 failed\n")); + + char conbuf[30]; // Buffer to receive response. + + int i = 0; + + for (char c = ' '; c != '!'; i++) + { + if (c_stream.recv (&c, 1) == -1) + ACE_DEBUG ((LM_DEBUG, + "(%t) buffer recv from peer1 failed\n")); + else + conbuf[i] = c; + } + + conbuf[i] = '\0'; + ACE_DEBUG ((LM_DEBUG, + "(%t) peer1 received buffer with \"%s\"\n", + conbuf)); + c_stream.close (); + return 0; +} + +static void * +peer2 (void *) +{ + // Insert thread into thr_mgr. + ACE_Thread_Control thread_control (&thr_mgr); + + ACE_UPIPE_Addr serv_addr ("pattern"); + ACE_UPIPE_Acceptor acc (addr); + ACE_UPIPE_Stream s_stream; + + // Spawn a peer1 thread. + if (thr_mgr.spawn (ACE_THR_FUNC (peer1), (void *) 0, + THR_NEW_LWP | THR_DETACHED) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), 0); + + ACE_DEBUG ((LM_DEBUG, "(%t) peer2 starting accept\n")); + + if (acc.accept (s_stream) == -1) + ACE_DEBUG ((LM_DEBUG, + "(%t) ACE_UPIPE_Acceptor.accept failed\n")); + + ACE_Message_Block *mb = 0; + + if (s_stream.recv (mb) == -1) + ACE_DEBUG ((LM_DEBUG, "(%t) peer2 recv failed\n")); + + ACE_DEBUG ((LM_DEBUG, "(%t) peer2 recv is \"%s\"\n", + mb->rd_ptr ())); + + mb->wr_ptr (mb->rd_ptr ()); + mb->copy ("thanks", 7); + + if (s_stream.send (mb) == -1) + ACE_DEBUG ((LM_DEBUG, "(%t) peer2 send failed\n")); + + char s_buf[42]; + ACE_DEBUG ((LM_DEBUG, "(%t) peer2 sleeping on recv\n")); + + if (s_stream.recv (s_buf, sizeof s_buf) == -1) + ACE_DEBUG ((LM_DEBUG, "(%t) peer2 recv failed\n")); + else + ACE_DEBUG ((LM_DEBUG, + "(%t) peer2 received buffer with \"%s\"\n", + s_buf)); + + ACE_OS::strcpy (s_buf, "this is the peer2 response!"); + + if (s_stream.send (s_buf, 30) == -1) + ACE_DEBUG ((LM_DEBUG, "(%t) peer2 send failed\n")); + + s_stream.close (); + return 0; +} + +int +main (int, char *[]) +{ + // Spawn a peer2 thread. + if (thr_mgr.spawn (ACE_THR_FUNC (peer2), (void *) 0, + THR_NEW_LWP | THR_DETACHED) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), 1); + + // Wait for peer2 and peer1 threads to exit. + thr_mgr.wait (); + return 0; +} +#else +int +main (int, char *[]) +{ + ACE_ERROR_RETURN ((LM_ERROR, "threads not supported on this platform\n"), -1); +} +#endif /* ACE_HAS_THREADS */ diff --git a/examples/IPC_SAP/UPIPE_SAP/ex2.cpp b/examples/IPC_SAP/UPIPE_SAP/ex2.cpp new file mode 100644 index 00000000000..5677fd0ae4c --- /dev/null +++ b/examples/IPC_SAP/UPIPE_SAP/ex2.cpp @@ -0,0 +1,153 @@ +// Example for using ACE_UPIPE_SAP and ACE_Thread for intra-process +// @(#)ex2.cpp 1.1 10/18/96 + +// communication. +// +// Author : Gerhard Lenzer and Douglas C. Schmidt + +#include <fstream.h> +#include "ace/Log_Msg.h" +#include "ace/UPIPE_Connector.h" +#include "ace/UPIPE_Acceptor.h" +#include "auto_builtin_ptr.h" + +#if defined (ACE_HAS_THREADS) + +// Global thread manager. +static ACE_Thread_Manager thr_mgr; + +// Data for testsuite. +int size = 0; +int iterations = 0; + +static void * +supplier (void *) +{ + // Insert thread into thr_mgr. + ACE_Thread_Control thread_control (&thr_mgr); + ACE_UPIPE_Stream s_stream; + + ACE_UPIPE_Addr c_addr ("pattern"); + + auto_builtin_ptr <char> mybuf = new char[size]; + + for (int i = 0; i < size; i++) + mybuf[i] = 'a'; + + ACE_DEBUG ((LM_DEBUG, "(%t) supplier starting connect thread\n")); + + ACE_UPIPE_Connector con; + + if (con.connect (s_stream, c_addr) == -1) + ACE_DEBUG ((LM_DEBUG, "(%t) %p\n", + "ACE_UPIPE_Acceptor.connect failed")); + + // Test asynchronisity. + s_stream.enable (SIGIO); + + for (int j = 0; j < iterations; j++) + { + ACE_Message_Block *mb_p = + new ACE_Message_Block (size, ACE_Message_Block::MB_DATA, + (ACE_Message_Block *) 0, mybuf); + + if (s_stream.send (mb_p) == -1) + { + ACE_DEBUG ((LM_DEBUG, "(%t) %p\n", "send failed")); + return 0; + } + } + + // Insert a 0-sized message block to signal the other side to shut + // down. + if (s_stream.send (new ACE_Message_Block ((size_t) 0)) == -1) + { + cout << "error put" << endl; + return 0; + } + + s_stream.close (); + return 0; +} + +static void * +consumer (void *) +{ + // Insert thread into thr_mgr. + ACE_Thread_Control thread_control (&thr_mgr); + ACE_UPIPE_Stream c_stream; + + // Set the high water mark to size to achieve optimum performance. + + int wm = size * iterations; + + if (c_stream.control (ACE_IO_Cntl_Msg::SET_HWM, &wm) == -1) + ACE_DEBUG ((LM_DEBUG, "set HWM failed\n")); + + ACE_UPIPE_Addr serv_addr ("pattern"); + + ACE_UPIPE_Acceptor acc (serv_addr); // accept will wait up to 4 seconds + + ACE_DEBUG ((LM_DEBUG, "(%t) consumer spawning the supplier thread\n")); + + // Spawn the supplier thread. + if (thr_mgr.spawn (ACE_THR_FUNC (supplier), (void *) 0, + THR_NEW_LWP | THR_DETACHED) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), 0); + + ACE_DEBUG ((LM_DEBUG, "(%t) consumer starting accept\n")); + + if (acc.accept (c_stream) == -1) + ACE_DEBUG ((LM_DEBUG, "(%t) %p\n", + "ACE_UPIPE_Acceptor.accept failed")); + + // time measurement + time_t currsec; + ACE_OS::time (&currsec); + time_t start = (time_t) currsec; + + int received_messages = 0; + + for (ACE_Message_Block *mb = 0; + c_stream.recv (mb) != -1 && mb->size () != 0; + delete mb) + received_messages++; + + ACE_OS::time (&currsec); + time_t secs = (time_t) currsec - start; + + ACE_DEBUG ((LM_DEBUG, + "(%t) Transferred %d blocks of size %d\n" + "The program ran %d seconds\n", + received_messages, size, secs)); + + c_stream.close (); + return 0; +} + +int +main (int argc, char *argv[]) +{ + size = argc > 1 ? ACE_OS::atoi (argv[1]) : 32; + iterations = argc > 2 ? ACE_OS::atoi (argv[2]) : 16; + + // Spawn the two threads. + if (thr_mgr.spawn (ACE_THR_FUNC (consumer), (void *) 0, + THR_NEW_LWP | THR_DETACHED) == -1) + ACE_ERROR_RETURN ( (LM_ERROR, "%p\n", "spawn"), 1); + + // Wait for producer and consumer threads to exit. + thr_mgr.wait (); + return 0; +} + +#else +int +main (int, char *[]) +{ + ACE_ERROR ( (LM_ERROR, "threads not supported on this platform\n")); + return 0; +} +#endif /* ACE_HAS_THREADS */ + + diff --git a/examples/IPC_SAP/UPIPE_SAP/ex3.cpp b/examples/IPC_SAP/UPIPE_SAP/ex3.cpp new file mode 100644 index 00000000000..55568f24ef8 --- /dev/null +++ b/examples/IPC_SAP/UPIPE_SAP/ex3.cpp @@ -0,0 +1,147 @@ +// Example for using ACE_UPIPE_SAP and ACE_Thread for intra-process +// @(#)ex3.cpp 1.1 10/18/96 + +// communication. This example uses char buffers as input/output +// interface to the ACE_UPIPE_Stream +// +// Authors: Gerhard Lenzer and Prashant Jain. + +#include <fstream.h> +#include "ace/Log_Msg.h" +#include "ace/UPIPE_Connector.h" +#include "ace/UPIPE_Acceptor.h" +#include "auto_builtin_ptr.h" + +#if defined (ACE_HAS_THREADS) + +// Global thread manager. +static ACE_Thread_Manager thr_mgr; + +// Data for testsuite. +int size = 0; +int iterations = 0; + +static void * +supplier (void *) +{ + // Insert thread into thr_mgr. + ACE_Thread_Control thread_control (&thr_mgr); + + ACE_UPIPE_Stream s_stream; + ACE_UPIPE_Addr c_addr ("pattern"); + + ACE_UPIPE_Connector con; + + ACE_DEBUG ((LM_DEBUG, "(%t) supplier starting connect thread\n")); + + if (con.connect (s_stream, c_addr) == -1) + ACE_DEBUG ((LM_DEBUG, "(%t) %p\n", + "ACE_UPIPE_Acceptor.connect failed")); + + auto_builtin_ptr <char> mybuf = new char[size]; + + for (int i = 0; i < size; i++) + mybuf[i] = 'a'; + + for (int j = 0; j < iterations; j++) + if (s_stream.send (mybuf, size) == -1) + { + ACE_DEBUG ((LM_DEBUG, "(%t) %p\n", "send failed")); + return 0; + } + + // Insert a 0-sized message block to signal the other side to shut + // down. + if (s_stream.send (new ACE_Message_Block ((size_t) 0)) == -1) + { + cout << "error put" << endl; + return 0; + } + + s_stream.close (); + return 0; +} + +static void * +consumer (void *) +{ + // Insert thread into thr_mgr. + ACE_Thread_Control thread_control (&thr_mgr); + + ACE_UPIPE_Stream c_stream; + ACE_UPIPE_Addr serv_addr ("pattern"); + + // Accept will wait up to 4 seconds + ACE_UPIPE_Acceptor acc (serv_addr); + + ACE_DEBUG ((LM_DEBUG, "(%t) consumer spawning the supplier thread\n")); + + // Spawn the supplier thread. + if (thr_mgr.spawn (ACE_THR_FUNC (supplier), (void *) 0, + THR_NEW_LWP | THR_DETACHED) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), 0); + + ACE_DEBUG ((LM_DEBUG, "(%t) consumer starting accept\n")); + + if (acc.accept (c_stream) == -1) + ACE_DEBUG ((LM_DEBUG, "(%t) %p\n", + "ACE_UPIPE_Acceptor.accept failed")); + + // Ensure deletion upon exit. + auto_builtin_ptr <char> mybuf = new char[size]; + time_t currsec; + + ACE_OS::time (&currsec); + + time_t start = (time_t) currsec; + int result = 0; + int blocks = 0; + + for (;; blocks++) + { + result = c_stream.recv (mybuf, size); + if (result <= 0) + break; + // ACE_DEBUG ((LM_DEBUG, "(%t) %d: %s\n", size, (char *) mybuf)); + } + + if (result == -1) + ACE_DEBUG ((LM_DEBUG, "(%t) %p\n", "recv failed")); + + ACE_OS::time (&currsec); + time_t secs = (time_t) currsec - start; + + ACE_DEBUG ((LM_DEBUG, + "(%t) Transferred %d blocks of size %d\n" + "The program ran %d seconds\n", + blocks, size, secs)); + + c_stream.close (); + return 0; +} + +int +main (int argc, char *argv[]) +{ + size = argc > 1 ? ACE_OS::atoi (argv[1]) : 32; + iterations = argc > 2 ? ACE_OS::atoi (argv[2]) : 16; + + // Spawn the thread. + if (thr_mgr.spawn (ACE_THR_FUNC (consumer), (void *) 0, + THR_NEW_LWP | THR_DETACHED) == -1) + ACE_ERROR_RETURN ( (LM_ERROR, "%p\n", "spawn"), 1); + + // Wait for producer and consumer threads to exit. + thr_mgr.wait (); + return 0; +} +#else +int +main (int, char *[]) +{ + ACE_ERROR ( (LM_ERROR, "threads not supported on this platform\n")); + return 0; +} +#endif /* ACE_HAS_THREADS */ + + diff --git a/examples/Log_Msg/Makefile b/examples/Log_Msg/Makefile new file mode 100644 index 00000000000..9949795ba24 --- /dev/null +++ b/examples/Log_Msg/Makefile @@ -0,0 +1,55 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for testing the Log_Msg logger +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = test_log_msg + +LSRC = $(addsuffix .cpp,$(BIN)) + +LDLIBS = + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/test_log_msg.o .shobj/test_log_msg.so: test_log_msg.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/Log_Msg/test_log_msg.cpp b/examples/Log_Msg/test_log_msg.cpp new file mode 100644 index 00000000000..1f93dcc20b0 --- /dev/null +++ b/examples/Log_Msg/test_log_msg.cpp @@ -0,0 +1,105 @@ +// Test the Log_Msg abstraction. +// @(#)test_log_msg.cpp 1.1 10/18/96 + + +#include "ace/Log_Msg.h" + +static void +cleanup (void) +{ + ACE_DEBUG ((LM_INFO, "leaving (%P)!\n")); +} + +static void +cause_error (void) +{ + errno = EWOULDBLOCK; + ACE_ERROR ((LM_DEBUG, "would block\n")); +} + +int +main (int argc, char *argv[]) +{ + // Note that the default behavior is to log to STDERR... + + if (argc > 1) + { + if (ACE_LOG_MSG->open (argv[0], ACE_Log_Msg::OSTREAM) == -1) + ACE_ERROR ((LM_ERROR, "cannot open logger!!!\n")); + + cause_error (); + // Check to see what happened. + if (ACE_LOG_MSG->op_status () == -1 + && ACE_LOG_MSG->errnum () == EWOULDBLOCK) + ACE_DEBUG ((LM_DEBUG, "op_status and errnum work!\n")); + else + ACE_ERROR ((LM_ERROR, "op_status and errnum failed!\n")); + } + else + { + if (ACE_LOG_MSG->open (argv[0]) == -1) + ACE_ERROR ((LM_ERROR, "cannot open logger!!!\n")); + + cause_error (); + + // Check to see what happened. + if (ACE_LOG_MSG->op_status () == -1 + && ACE_LOG_MSG->errnum () == EWOULDBLOCK) + ACE_DEBUG ((LM_DEBUG, "op_status and errnum work!\n")); + else + ACE_ERROR ((LM_ERROR, "op_status and errnum failed!\n")); + + // Exercise many different combinations of STDERR and OSTREAM. + + ACE_DEBUG ((LM_INFO, "%f, %*s%s = %d\n", + 3.1416, 8, "", "hello", 10000)); + + ACE_LOG_MSG->set_flags (ACE_Log_Msg::OSTREAM); + ACE_LOG_MSG->msg_ostream (&cout); + + ACE_DEBUG ((LM_INFO, "%f, %*s%s = %d\n", + 3.1416 * 3.1416, 8, "", "world", 20000)); + + ACE_LOG_MSG->clr_flags (ACE_Log_Msg::STDERR); + + ACE_DEBUG ((LM_INFO, "%f, %*s%s = %d\n", + 3.1416 * 3.1416, 8, "", "world", 20000)); + + ACE_LOG_MSG->msg_ostream (0); + + ACE_LOG_MSG->set_flags (ACE_Log_Msg::STDERR); + + ACE_DEBUG ((LM_INFO, "%f, %*s%s = %d\n", + 3.1416 * 3.1416, 8, "", "world", 20000)); + + ACE_LOG_MSG->clr_flags (ACE_Log_Msg::OSTREAM); + ACE_LOG_MSG->msg_ostream (&cerr); + + ACE_DEBUG ((LM_INFO, "%f, %*s%s = %d\n", + 3.1416 * 3.1416, 8, "", "world", 20000)); + + static int array[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048}; + + // Print out the binary bytes of the array in hex form. + ACE_LOG_MSG->log_hexdump (LM_DEBUG, (char *) array, sizeof array); + + // Disable the LM_DEBUG and LM_INFO messages. + int priority_mask = ACE_LOG_MSG->priority_mask (); + ACE_CLR_BITS (priority_mask, LM_DEBUG | LM_INFO); + ACE_LOG_MSG->priority_mask (priority_mask); + + ACE_DEBUG ((LM_INFO, "This LM_INFO message should not print!\n")); + ACE_DEBUG ((LM_DEBUG, "This LM_DEBUG message should not print!\n")); + + char *badname = "badname"; + + char *l_argv[2]; + l_argv[0] = badname; + l_argv[1] = 0; + + if (ACE_OS::execv (badname, l_argv) == -1) + ACE_ERROR ((LM_ERROR, "%n: (%x), %p%r%a\n", + 10000, badname, cleanup, 1)); + } + return 0; +} diff --git a/examples/Logger/Acceptor-server/Makefile b/examples/Logger/Acceptor-server/Makefile new file mode 100644 index 00000000000..caf3e445e80 --- /dev/null +++ b/examples/Logger/Acceptor-server/Makefile @@ -0,0 +1,107 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the Reactor version of the Server Logging Daemon +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = server_loggerd + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.lib.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/Logging_Acceptor.o .shobj/Logging_Acceptor.so: Logging_Acceptor.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + Logging_Acceptor.h \ + $(WRAPPER_ROOT)/ace/Singleton.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/SOCK_Acceptor.h \ + Logging_Handler.h +.obj/Logging_Handler.o .shobj/Logging_Handler.so: Logging_Handler.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + Logging_Handler.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/Logger/Acceptor-server/server_loggerd.cpp b/examples/Logger/Acceptor-server/server_loggerd.cpp new file mode 100644 index 00000000000..f8d6008948d --- /dev/null +++ b/examples/Logger/Acceptor-server/server_loggerd.cpp @@ -0,0 +1,268 @@ +// This server daemon collects, formats, and displays logging +// @(#)server_loggerd.cpp 1.1 10/18/96 + +// information forwarded from client daemons running on other hosts in +// the network. In addition, this example illustrates how to use the +// ACE_Reactor, ACE_Acceptor, ACE_Singleton, and ACE_Test_and_Set +// components. + +#include "ace/Get_Opt.h" +#include "ace/Log_Msg.h" +#include "ace/Acceptor.h" +#include "ace/SOCK_Acceptor.h" +#include "ace/Synch.h" +#include "ace/Singleton.h" + +// ---------------------------------------- + +class Options +{ + // = TITLE + // Keeps track of the options. +public: + void parse_args (int argc, char *argv[]); + u_short port (void); + +private: + u_short port_; + // Port number; +}; + +// Return the port number. + +u_short +Options::port (void) +{ + return this->port_; +} + +// Parse the command-line options. + +void +Options::parse_args (int argc, char *argv[]) +{ + this->port_ = ACE_DEFAULT_SERVER_PORT; + + ACE_Get_Opt get_opt (argc, argv, "p:"); + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'p': + this->port_ = ACE_OS::atoi (get_opt.optarg); + break; + default: + break; + } +} + +// ---------------------------------------- + +// Our Reactor Singleton. +typedef ACE_Singleton<ACE_Reactor, ACE_Null_Mutex> + REACTOR; + +// Our Options Singleton. +typedef ACE_Singleton<Options, ACE_Null_Mutex> + OPTIONS; + +// Our ACE_Test_and_Set Singleton. +typedef ACE_Singleton<ACE_Test_and_Set <ACE_Null_Mutex, sig_atomic_t>, ACE_Null_Mutex> + QUIT_HANDLER; + +// ---------------------------------------- + +class Logging_Handler : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> + // = TITLE + // Receive client message from the remote clients. + // + // = DESCRIPTION + // This class demonstrates how to receive messages from remote + // clients using the notification mechanisms in the + // <ACE_Reactor>. In addition, it also illustrates how to + // utilize the <ACE_Reactor> timer mechanisms, as well. +{ +public: + // = Initialization and termination methods. + Logging_Handler (void); + + virtual void destroy (void); + // Ensure dynamic allocation. + + // = Hooks for opening and closing handlers. + virtual int open (void *); + virtual int close (u_long); + +protected: + // = Demultiplexing hooks. + virtual int handle_input (ACE_HANDLE); + virtual int handle_timeout (const ACE_Time_Value &tv, + const void *arg); + +private: + char peer_name_[MAXHOSTNAMELEN + 1]; + // Host we are connected to. +}; + +// Specialize a Logging Acceptor. +typedef ACE_Acceptor <Logging_Handler, ACE_SOCK_ACCEPTOR> + Logging_Acceptor; + +// Default constructor. + +Logging_Handler::Logging_Handler (void) +{ +} + +void +Logging_Handler::destroy (void) +{ + REACTOR::instance ()->cancel_timer (this); + this->peer ().close (); +} + +int +Logging_Handler::handle_timeout (const ACE_Time_Value &, + const void *arg) +{ + ACE_ASSERT (arg == this); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) handling timeout from this = %u\n", this)); + return 0; +} + +// Perform the logging record receive. + +int +Logging_Handler::handle_input (ACE_HANDLE) +{ + // Perform two recv's to emulate record-oriented semantics. Note + // that this code is not entirely portable since it relies on the + // fact that sizeof (ssize_t) is the same on both the sender and + // receiver side. To correctly handle this is painful, and we leave + // it as an exercise for the reader ;-). + + ssize_t len; + ssize_t n = this->peer ().recv ((void *) &len, sizeof len); + + switch (n) + { + case -1: + ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p at host %s\n", + "client logger", this->peer_name_), -1); + /* NOTREACHED */ + case 0: + ACE_ERROR_RETURN ((LM_ERROR, + "(%P|%t) closing log daemon at host %s (fd = %d)\n", + this->peer_name_, this->get_handle ()), -1); + /* NOTREACHED */ + case sizeof (size_t): + { + ACE_Log_Record lp; + + len = ntohl (len); + if ((n = this->peer ().recv_n ((void *) &lp, len)) != len) + ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p at host %s\n", + "client logger", this->peer_name_), -1); + /* NOTREACHED */ + + lp.decode (); + + if (lp.length () == n) + { + ACE_DEBUG ((LM_DEBUG, "(%P|%t) ")); + lp.print (this->peer_name_, 1, cerr); + } + else + ACE_ERROR ((LM_ERROR, "(%P|%t) error, lp.length = %d, n = %d\n", + lp.length (), n)); + break; + } + default: + ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p at host %s\n", + "client logger", this->peer_name_), -1); + /* NOTREACHED */ + } + + return 0; +} + +int +Logging_Handler::open (void *) +{ + ACE_INET_Addr addr; + + if (this->peer ().get_remote_addr (addr) == -1) + return -1; + else + { + ACE_OS::strncpy (this->peer_name_, + addr.get_host_name (), + MAXHOSTNAMELEN + 1); + + if (REACTOR::instance ()->register_handler + (this, ACE_Event_Handler::READ_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "(%P|%t) can't register with reactor\n"), -1); + else if (REACTOR::instance ()->schedule_timer + (this, + (const void *) this, + ACE_Time_Value (2), + ACE_Time_Value (2)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "can'(%P|%t) t register with reactor\n"), -1); + else + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) connected with %s\n", this->peer_name_)); + return 0; + } +} + +// Perform termination activities when deregistered from the +// ACE_Reactor. + +int +Logging_Handler::close (u_long) +{ + this->destroy (); + return 0; +} + +int +main (int argc, char *argv[]) +{ + // Acceptor factory. + Logging_Acceptor peer_acceptor; + + OPTIONS::instance ()->parse_args (argc, argv); + + if (peer_acceptor.open + (ACE_INET_Addr (OPTIONS::instance ()->port ())) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); + + else if (REACTOR::instance ()->register_handler + (&peer_acceptor, ACE_Event_Handler::READ_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "registering service with ACE_Reactor\n"), -1); + + // Register QUIT_HANDLER to receive SIGINT commands. When received, + // QUIT_HANDLER becomes "set" and thus, the event loop below will + // exit. + else if (REACTOR::instance ()->register_handler + (SIGINT, QUIT_HANDLER::instance ()) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "registering service with ACE_Reactor\n"), -1); + + // Run forever, performing logging service. + + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) starting up server logging daemon\n")); + + // Perform logging service until QUIT_HANDLER receives SIGINT. + while (QUIT_HANDLER::instance ()->is_set () == 0) + REACTOR::instance ()->handle_events (); + + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) shutting down server logging daemon\n")); + + return 0; +} diff --git a/examples/Logger/Makefile b/examples/Logger/Makefile new file mode 100644 index 00000000000..05c41ee6fc2 --- /dev/null +++ b/examples/Logger/Makefile @@ -0,0 +1,27 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the distributed logger tests +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +INFO = README + +DIRS = Acceptor-server \ + client \ + simple-server + + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nolocal.GNU + diff --git a/examples/Logger/README b/examples/Logger/README new file mode 100644 index 00000000000..9fa30aafbc0 --- /dev/null +++ b/examples/Logger/README @@ -0,0 +1,32 @@ +This directory contains a simple client/server implementation of the +distributed logging server described in several papers in the C++ +Report (which can be obtained via the following WWW URLs: +http://www.cs.wustl.edu/~schmidt/{Reactor1-93.ps.gz,Reactor2-93.ps.gz}). + +The example consists of the following two directories: + + . client + + This program talks directly to the server logging + daemon. The server daemon must be started before you + can run this test. + + . simple-server + + This program runs a simple, non-templated, + single-threaded Reactive implementation of the + distributed logging server daemon. + + . Acceptor-server + + This program runs templated, Acceptor-based + single-threaded Reactive implementation of the + distributed logging server daemon. + +To see a more complex solution that implements the design described in +the C++ Report articles, please see the: + +$WRAPPER_ROOT/netsvcs/{clients,lib,servers} + +directories. + diff --git a/examples/Logger/client/Makefile b/examples/Logger/client/Makefile new file mode 100644 index 00000000000..665086e9d8f --- /dev/null +++ b/examples/Logger/client/Makefile @@ -0,0 +1,43 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for client logging applications +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = logging_app + +LSRC = $(addsuffix .cpp,$(BIN)) + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + + + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/Logger/client/logging_app.cpp b/examples/Logger/client/logging_app.cpp new file mode 100644 index 00000000000..0875092cc61 --- /dev/null +++ b/examples/Logger/client/logging_app.cpp @@ -0,0 +1,53 @@ +// This program sends logging records directly to the server, rather +// @(#)logging_app.cpp 1.1 10/18/96 + +// than going through the client logging daemon. + +#include "ace/SOCK_Connector.h" +#include "ace/Log_Msg.h" +#include "ace/Log_Record.h" + +static u_short LOGGER_PORT = ACE_DEFAULT_SERVER_PORT; +static const char *const LOGGER_HOST = ACE_DEFAULT_SERVER_HOST; +static const int MAX_ITERATIONS = 10; + +int +main (int argc, char *argv[]) +{ + const char *logger_host = argc > 1 ? argv[1] : LOGGER_HOST; + u_short logger_port = argc > 2 ? ACE_OS::atoi (argv[2]) : LOGGER_PORT; + int max_iterations = argc > 3 ? ACE_OS::atoi (argv[3]) : MAX_ITERATIONS; + + ACE_SOCK_Stream logger; + ACE_SOCK_Connector connector; + ACE_INET_Addr addr (logger_port, logger_host); + + if (connector.connect (logger, addr) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); + + for (int i = 0; i < max_iterations; i++) + { + ACE_Log_Record log_record (LM_DEBUG, + ACE_OS::time ((time_t *) 0), + ACE_OS::getpid ()); + + char buf[BUFSIZ]; + ::sprintf (buf, "message = %d\n", i + 1); + log_record.msg_data (buf); + size_t len = log_record.length (); + size_t encoded_len = htonl (len); + + log_record.encode (); + + if (logger.send (4, &encoded_len, sizeof encoded_len, + (char *) &log_record, len) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send"), -1); + else + ACE_OS::sleep (1); + } + + if (logger.close () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), -1); + + return 0; +} diff --git a/examples/Logger/simple-server/Logging_Acceptor.cpp b/examples/Logger/simple-server/Logging_Acceptor.cpp new file mode 100644 index 00000000000..75e35dec595 --- /dev/null +++ b/examples/Logger/simple-server/Logging_Acceptor.cpp @@ -0,0 +1,64 @@ +#include "ace/Log_Msg.h" +// @(#)Logging_Acceptor.cpp 1.1 10/18/96 + +#include "Logging_Acceptor.h" +#include "Logging_Handler.h" +#include "Reactor_Singleton.h" + +// Initialize peer_acceptor object. + +int +Logging_Acceptor::open (const ACE_INET_Addr &addr) +{ + // Reuse addr if already in use. + if (this->peer_acceptor_.open (addr, 1) == -1) + return -1; + else + return 0; +} + +// Default constructor. + +Logging_Acceptor::Logging_Acceptor (void) +{ +} + +// Performs termination activities. + +int +Logging_Acceptor::handle_close (ACE_HANDLE, ACE_Reactor_Mask) +{ + return this->peer_acceptor_.close (); +} + +Logging_Acceptor::~Logging_Acceptor (void) +{ + this->handle_close (ACE_INVALID_HANDLE, + ACE_Event_Handler::READ_MASK); +} + +// Returns underlying device descriptor. + +ACE_HANDLE +Logging_Acceptor::get_handle (void) const +{ + return this->peer_acceptor_.get_handle (); +} + +// Accepts connections from client and registers new object with the +// ACE_Reactor. + +int +Logging_Acceptor::handle_input (ACE_HANDLE) +{ + Logging_Handler *svc_handler = new Logging_Handler; + + // Accept the connection from a client client daemon. + + if (this->peer_acceptor_.accept (*svc_handler) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p", "accept failed"), -1); + else if (svc_handler->open () == -1) + svc_handler->close (); + + return 0; +} diff --git a/examples/Logger/simple-server/Logging_Acceptor.h b/examples/Logger/simple-server/Logging_Acceptor.h new file mode 100644 index 00000000000..bb431f0150f --- /dev/null +++ b/examples/Logger/simple-server/Logging_Acceptor.h @@ -0,0 +1,49 @@ +/* -*- C++ -*- */ +// @(#)Logging_Acceptor.h 1.1 10/18/96 + + +// ============================================================================ +// +// = LIBRARY +// examples +// +// = FILENAME +// Logging_Acceptor.h +// +// = AUTHOR +// Doug Schmidt +// +// ============================================================================ + +#if !defined (_CLIENT_ACCEPTOR_H) +#define _CLIENT_ACCEPTOR_H + +#include "ace/SOCK_Acceptor.h" +#include "ace/Event_Handler.h" + +class Logging_Acceptor : public ACE_Event_Handler + // = TITLE + // Handle connection requests from remote client clients. + // + // = DESCRIPTION + // Accepts client connection requests, creates Logging_Handler's + // to process them, and registers these Handlers with the + // ACE_Reactor Singleton. +{ +friend class Logging_Handler; +public: + Logging_Acceptor (void); + ~Logging_Acceptor (void); + + int open (const ACE_INET_Addr &a); + +private: + virtual ACE_HANDLE get_handle (void) const; + virtual int handle_input (ACE_HANDLE); + virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask); + + ACE_SOCK_Acceptor peer_acceptor_; + // Passive connection acceptor factory. +}; + +#endif /* _CLIENT_ACCEPTOR_H */ diff --git a/examples/Logger/simple-server/Logging_Handler.cpp b/examples/Logger/simple-server/Logging_Handler.cpp new file mode 100644 index 00000000000..5aba39d7601 --- /dev/null +++ b/examples/Logger/simple-server/Logging_Handler.cpp @@ -0,0 +1,139 @@ +#include "ace/Log_Msg.h" +// @(#)Logging_Handler.cpp 1.1 10/18/96 + +#include "Logging_Handler.h" +#include "Reactor_Singleton.h" + +// Default constructor. + +Logging_Handler::Logging_Handler (void) +{ +} + +Logging_Handler::~Logging_Handler (void) +{ + REACTOR::instance ()->cancel_timer (this); + this->cli_stream_.close (); +} + +// Extract the underlying ACE_SOCK_Stream (e.g., for purposes of +// accept()). + +Logging_Handler::operator ACE_SOCK_Stream &() +{ + return this->cli_stream_; +} + +int +Logging_Handler::handle_timeout (const ACE_Time_Value &, + const void *arg) +{ + ACE_ASSERT (arg == this); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) handling timeout from this = %u\n", this)); + return 0; +} + +// Perform the logging record receive. + +int +Logging_Handler::handle_input (ACE_HANDLE) +{ + ssize_t n; + size_t len; + + // Perform two recv's to emulate record-oriented semantics. Note + // that this code is not entirely portable since it relies on the + // fact that sizeof (ssize_t) is the same on both the sender and + // receiver side. To correctly handle this is painful, and we leave + // it as an exercise for the reader ;-). + + switch (n = this->cli_stream_.recv ((void *) &len, sizeof len)) + { + case -1: + ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p at host %s\n", + "client logger", this->host_name_), -1); + /* NOTREACHED */ + case 0: + ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) closing log daemon at host %s (fd = %d)\n", + this->host_name_, this->get_handle ()), -1); + /* NOTREACHED */ + case sizeof (size_t): + { + ACE_Log_Record lp; + + len = ntohl (len); + if ((n = this->cli_stream_.recv_n ((void *) &lp, len)) != len) + ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p at host %s\n", + "client logger", this->host_name_), -1); + /* NOTREACHED */ + + lp.decode (); + + if (lp.length () == n) + { + ACE_DEBUG ((LM_DEBUG, "(%P|%t) ")); + lp.print (this->host_name_, 1, cerr); + } + else + ACE_ERROR ((LM_ERROR, "(%P|%t) error, lp.length = %d, n = %d\n", + lp.length (), n)); + break; + } + default: + ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p at host %s\n", + "client logger", this->host_name_), -1); + /* NOTREACHED */ + } + + return 0; +} + +// Extract underlying device descriptor. + +ACE_HANDLE +Logging_Handler::get_handle (void) const +{ + return this->cli_stream_.get_handle (); +} + +int +Logging_Handler::open (void) +{ + ACE_INET_Addr addr; + + if (this->cli_stream_.get_remote_addr (addr) == -1) + return -1; + else + { + ACE_OS::strncpy (this->host_name_, addr.get_host_name (), MAXHOSTNAMELEN + 1); + + if (REACTOR::instance ()->register_handler + (this, ACE_Event_Handler::READ_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) can't register with reactor\n"), -1); + else if (REACTOR::instance ()->schedule_timer + (this, (const void *) this, ACE_Time_Value (2), ACE_Time_Value (2)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "can'(%P|%t) t register with reactor\n"), -1); + else + ACE_DEBUG ((LM_DEBUG, "(%P|%t) connected with %s\n", this->host_name_)); + return 0; + } +} + +// Perform termination activities when deregistered from the ACE_Reactor. + +int +Logging_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) +{ + // Must be allocated dynamically! + delete this; + return 0; +} + +// Perform termination activities when close fails. + +int +Logging_Handler::close (void) +{ + return this->handle_close (ACE_INVALID_HANDLE, + ACE_Event_Handler::RWE_MASK); +} diff --git a/examples/Logger/simple-server/Logging_Handler.h b/examples/Logger/simple-server/Logging_Handler.h new file mode 100644 index 00000000000..f26a83df550 --- /dev/null +++ b/examples/Logger/simple-server/Logging_Handler.h @@ -0,0 +1,64 @@ +/* -*- C++ -*- */ +// @(#)Logging_Handler.h 1.1 10/18/96 + + +// ============================================================================ +// +// = LIBRARY +// examples +// +// = FILENAME +// Logging_Handler.h +// +// = AUTHOR +// Doug Schmidt +// +// ============================================================================ + +#if !defined (_CLIENT_HANDLER_H) +#define _CLIENT_HANDLER_H + +#include "ace/Event_Handler.h" +#include "ace/INET_Addr.h" +#include "ace/SOCK_Stream.h" + +class Logging_Handler : public ACE_Event_Handler + // = TITLE + // Receive client message from the remote clients. + // + // = DESCRIPTION + // This class demonstrates how to receive messages from remote + // clients using the notification mechanisms in the + // <ACE_Reactor>. In addition, it also illustrates how to + // utilize the <ACE_Reactor> timer mechanisms, as well. +{ +public: + Logging_Handler (void); + + // = Hooks for opening and closing handlers. + virtual int open (void); + virtual int close (void); + + operator ACE_SOCK_Stream &(); + // Conversion operators. + +protected: + // = Demultiplexing hooks. + virtual ACE_HANDLE get_handle (void) const; + virtual int handle_input (ACE_HANDLE); + virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask); + virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg); + + // = Really should be private... + virtual ~Logging_Handler (void); + // Ensure dynamic allocation. + +private: + char host_name_[MAXHOSTNAMELEN + 1]; + // Host we are connected to. + + ACE_SOCK_Stream cli_stream_; + // Connection with client +}; + +#endif /* _CLIENT_HANDLER_H */ diff --git a/examples/Logger/simple-server/Makefile b/examples/Logger/simple-server/Makefile new file mode 100644 index 00000000000..773d9f513b8 --- /dev/null +++ b/examples/Logger/simple-server/Makefile @@ -0,0 +1,116 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the Reactor Server Logging Daemon +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = server_loggerd + +FILES = Logging_Acceptor \ + Logging_Handler + +LSRC = $(addsuffix .cpp,$(FILES)) +LOBJ = $(addsuffix .o,$(FILES)) +SHOBJ = $(addsuffix .so,$(FILES)) + +LDLIBS = $(addprefix .shobj/,$(SHOBJ)) + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.lib.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/Logging_Acceptor.o .shobj/Logging_Acceptor.so: Logging_Acceptor.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + Logging_Acceptor.h \ + $(WRAPPER_ROOT)/ace/Singleton.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/SOCK_Acceptor.h \ + Logging_Handler.h +.obj/Logging_Handler.o .shobj/Logging_Handler.so: Logging_Handler.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + Logging_Handler.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/Logger/simple-server/Reactor_Singleton.h b/examples/Logger/simple-server/Reactor_Singleton.h new file mode 100644 index 00000000000..7aa08b00f0b --- /dev/null +++ b/examples/Logger/simple-server/Reactor_Singleton.h @@ -0,0 +1,27 @@ +/* -*- C++ -*- */ +// @(#)Reactor_Singleton.h 1.1 10/18/96 + + +// ============================================================================ +// +// = LIBRARY +// examples +// +// = FILENAME +// Reactor_Singleton.h +// +// = AUTHOR +// Doug Schmidt +// +// ============================================================================ + +#if !defined (_REACTOR_SINGLETON_H) +#define _REACTOR_SINGLETON_H + +#include "ace/Singleton.h" +#include "ace/Reactor.h" + +// Our global Reactor Singleton. +typedef ACE_Singleton<ACE_Reactor, ACE_Null_Mutex> REACTOR; + +#endif /* _REACTOR_SINGLETON_H */ diff --git a/examples/Logger/simple-server/server_loggerd.cpp b/examples/Logger/simple-server/server_loggerd.cpp new file mode 100644 index 00000000000..9d0a03fd607 --- /dev/null +++ b/examples/Logger/simple-server/server_loggerd.cpp @@ -0,0 +1,61 @@ +// This server daemon collects, formats, and displays logging +// @(#)server_loggerd.cpp 1.1 10/18/96 + +// information forwarded from client daemons running on other hosts in +// the network. + +// In addition, it also illustrates how the ACE_Reactor framework is +// used. + +#include "ace/Get_Opt.h" +#include "ace/Log_Msg.h" +#include "Logging_Acceptor.h" +#include "Reactor_Singleton.h" + +static sig_atomic_t finished = 0; + +static void +handler (int) +{ + finished = 1; +} + +// It doesn't get anymore const than this.... +static const u_short PORT = ACE_DEFAULT_SERVER_PORT; + +int +main (int argc, char *argv[]) +{ + Logging_Acceptor peer_acceptor; + ACE_INET_Addr addr (PORT); + ACE_Get_Opt get_opt (argc, argv, "p:"); + + ACE_Sig_Action sig ((ACE_SignalHandler) handler, SIGINT); + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'p': + addr.set (ACE_OS::atoi (get_opt.optarg)); + break; + default: + break; + } + + if (peer_acceptor.open (addr) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); + else if (REACTOR::instance ()->register_handler + (&peer_acceptor, ACE_Event_Handler::READ_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "registering service with ACE_Reactor\n"), -1); + + // Run forever, performing logging service. + + ACE_DEBUG ((LM_DEBUG, "(%P|%t) starting up server logging daemon\n")); + + while (!finished) + REACTOR::instance ()->handle_events (); + + ACE_DEBUG ((LM_DEBUG, "(%P|%t) shutting down server logging daemon\n")); + + return 0; +} diff --git a/examples/Makefile b/examples/Makefile new file mode 100644 index 00000000000..577cc88a4fe --- /dev/null +++ b/examples/Makefile @@ -0,0 +1,39 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the tests directory +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +INFO = README + +DIRS = ASX \ + Connection \ + IPC_SAP \ + Logger \ + Log_Msg \ + Mem_Map \ + Misc \ + Reactor \ + Service_Configurator \ + Shared_Malloc \ + Threads + +# Makefiles TBD: +# ttcp +# CORBA + + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nolocal.GNU + diff --git a/examples/Mem_Map/IO-tests/IO_Test.cpp b/examples/Mem_Map/IO-tests/IO_Test.cpp new file mode 100644 index 00000000000..979fd724181 --- /dev/null +++ b/examples/Mem_Map/IO-tests/IO_Test.cpp @@ -0,0 +1,186 @@ +#include "ace/OS.h" +// @(#)IO_Test.cpp 1.1 10/18/96 + +#include "ace/Mem_Map.h" +#include "IO_Test.h" + +IO_Test::IO_Test (const char *name, ACE_Profile_Timer &tm) + : name_ (name), tm_ (tm) +{ +} + +const char * +IO_Test::name (void) +{ + return this->name_; +} + +Slow_Read_Write_Test::Slow_Read_Write_Test (char *name, ACE_Profile_Timer &tm) + : IO_Test (name, tm) +{ +} + +int +Slow_Read_Write_Test::run_test (int iterations, FILE *input_fp, FILE *output_fp) +{ + int ifd = fileno (input_fp); + int ofd = fileno (output_fp); + + this->tm_.start (); + + while (--iterations >= 0) + { + char c; + + while (ACE_OS::read (ifd, &c, sizeof c) > 0) + ::write (ofd, &c, sizeof c); + + ACE_OS::lseek (ifd, 0, SEEK_SET); + ACE_OS::lseek (ofd, 0, SEEK_SET); + } + + this->tm_.stop (); + return 0; +} + +Stdio_Test::Stdio_Test (char *name, ACE_Profile_Timer &tm) + : IO_Test (name, tm) +{ +} + +int +Stdio_Test::run_test (int iterations, FILE *input_fp, FILE *output_fp) +{ + this->tm_.start (); + + while (--iterations >= 0) + { + int c; + + while ((c = getc (input_fp)) != EOF) + putc (c, output_fp); + + ACE_OS::rewind (input_fp); + ACE_OS::rewind (output_fp); + } + this->tm_.stop (); + return 0; +} + +Block_Read_Write_Test::Block_Read_Write_Test (char *name, ACE_Profile_Timer &tm) + : IO_Test (name, tm) +{ +} + +int +Block_Read_Write_Test::run_test (int iterations, FILE *input_fp, FILE *output_fp) +{ + int ifd = fileno (input_fp); + int ofd = fileno (output_fp); + + this->tm_.start (); + + while (--iterations >= 0) + { + char buf[BUFSIZ]; + int n; + + while ((n = ACE_OS::read (ifd, buf, sizeof buf)) > 0) + ::write (ofd, buf, n); + + ACE_OS::lseek (ifd, 0, SEEK_SET); + ACE_OS::lseek (ofd, 0, SEEK_SET); + } + + this->tm_.stop (); + return 0; +} + +Block_Fread_Fwrite_Test::Block_Fread_Fwrite_Test (char *name, ACE_Profile_Timer &tm) + : IO_Test (name, tm) +{ +} + +int +Block_Fread_Fwrite_Test::run_test (int iterations, FILE *input_fp, FILE *output_fp) +{ + this->tm_.start (); + + while (--iterations >= 0) + { + char buf[BUFSIZ]; + int n; + + while ((n = ACE_OS::fread (buf, 1, sizeof buf, input_fp)) != 0) + ::fwrite (buf, n, 1, output_fp); + + ACE_OS::rewind (input_fp); + ACE_OS::rewind (output_fp); + } + + this->tm_.stop (); + return 0; +} + +Mmap1_Test::Mmap1_Test (char *name, ACE_Profile_Timer &tm) + : IO_Test (name, tm) +{ +} + +int +Mmap1_Test::run_test (int iterations, FILE *input_fp, FILE *output_fp) +{ + ACE_Mem_Map map_input (fileno (input_fp)); + void *src = 0; + + if (map_input (src) == -1) + return -1; + else + { + this->tm_.start (); + + while (--iterations >= 0) + if (ACE_OS::write (fileno (output_fp), src, map_input.size ()) == -1) + return -1; + + this->tm_.stop (); + } + + if (map_input.unmap () == -1) + return -1; + else + return 0; +} + +Mmap2_Test::Mmap2_Test (char *name, ACE_Profile_Timer &tm) + : IO_Test (name, tm) +{ +} + +int +Mmap2_Test::run_test (int iterations, FILE *input_fp, FILE *output_fp) +{ + ACE_Mem_Map map_input (fileno (input_fp)); + int size = map_input.size (); + ACE_Mem_Map map_output (fileno (output_fp), size, PROT_WRITE, MAP_SHARED); + void *src = 0; + void *dst = 0; + + if (map_input (src) == -1 || map_output (dst) == -1) + return -1; + else + { + this->tm_.start (); + + while (--iterations >= 0) + ACE_OS::memcpy (dst, src, size); + + this->tm_.stop (); + } + + if (map_input.unmap () == -1 + || map_output.unmap () == -1) + return -1; + else + return 0; +} diff --git a/examples/Mem_Map/IO-tests/IO_Test.h b/examples/Mem_Map/IO-tests/IO_Test.h new file mode 100644 index 00000000000..b45aabf17d9 --- /dev/null +++ b/examples/Mem_Map/IO-tests/IO_Test.h @@ -0,0 +1,71 @@ +/* -*- C++ -*- */ +// @(#)IO_Test.h 1.1 10/18/96 + +/* Class hierarchy for the File I/O tests. */ + +#include "ace/Profile_Timer.h" + +/* Base class for all the File I/O tests. */ + +class IO_Test +{ +public: + // Initialize the test name + IO_Test (const char *name, ACE_Profile_Timer &tm); + + // Return the name of the test + const char *name (void); + + // Execute the IO test (note this is a pure virtual function...) + virtual int run_test (int iterations, FILE *input_fp, FILE *output_fp) = 0; + +protected: + // Name of the test + const char *name_; + + // Reference to a timer + ACE_Profile_Timer &tm_; +}; + +class Slow_Read_Write_Test : public IO_Test +{ +public: + Slow_Read_Write_Test (char *name, ACE_Profile_Timer &tm); + virtual int run_test (int iterations, FILE *input_fp, FILE *output_fp); +}; + +class Stdio_Test : public IO_Test +{ +public: + Stdio_Test (char *name, ACE_Profile_Timer &tm); + virtual int run_test (int iterations, FILE *input_fp, FILE *output_fp); +}; + +class Block_Read_Write_Test : public IO_Test +{ +public: + Block_Read_Write_Test (char *name, ACE_Profile_Timer &tm); + virtual int run_test (int iterations, FILE *input_fp, FILE *output_fp); +}; + +class Block_Fread_Fwrite_Test : public IO_Test +{ +public: + Block_Fread_Fwrite_Test (char *name, ACE_Profile_Timer &tm); + virtual int run_test (int iterations, FILE *input_fp, FILE *output_fp); +}; + +class Mmap1_Test : public IO_Test +{ +public: + Mmap1_Test (char *name, ACE_Profile_Timer &tm); + virtual int run_test (int iterations, FILE *input_fp, FILE *output_fp); +}; + +class Mmap2_Test : public IO_Test +{ +public: + Mmap2_Test (char *name, ACE_Profile_Timer &tm); + virtual int run_test (int iterations, FILE *input_fp, FILE *output_fp); +}; + diff --git a/examples/Mem_Map/IO-tests/Makefile b/examples/Mem_Map/IO-tests/Makefile new file mode 100644 index 00000000000..c7f825136cb --- /dev/null +++ b/examples/Mem_Map/IO-tests/Makefile @@ -0,0 +1,63 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for Mem_Map IO tests +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = test_io + +FILES = IO_Test + +LSRC = $(addsuffix .cpp,$(FILES)) +LOBJ = $(addsuffix .o,$(FILES)) +SHOBJ = $(addsuffix .so,$(FILES)) + +LDLIBS = $(addprefix .shobj/,$(SHOBJ)) + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.lib.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/IO_Test.o .shobj/IO_Test.so: IO_Test.cpp \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + IO_Test.h \ + $(WRAPPER_ROOT)/ace/Profile_Timer.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/Mem_Map/IO-tests/test_io.cpp b/examples/Mem_Map/IO-tests/test_io.cpp new file mode 100644 index 00000000000..a9a9a918712 --- /dev/null +++ b/examples/Mem_Map/IO-tests/test_io.cpp @@ -0,0 +1,155 @@ +/* Test program for different methods of copying files. */ +// @(#)test_io.cpp 1.1 10/18/96 + + +#include "ace/OS.h" +#include "ace/Profile_Timer.h" +#include "ace/Get_Opt.h" +#include "ace/Signal.h" +#include "IO_Test.h" + +/* Name of program. */ +static char *program_name; + +/* Name of default input file. */ +static char *input_filename = "/usr/dict/words"; + +/* Name of default output file. */ +static char *output_filename = "/tmp/foo"; + +/* Check if removing output file upon completion... */ +static int remove_output = 1; + +/* Count of the number of iterations to run the tests. */ +static int iteration_count = 100; + +/* Profiler used to keep track of file I/O time. */ +static ACE_Profile_Timer tm; + +/* Explain usage and exit. */ + +static void +print_usage_and_die (void) +{ + cerr << "usage: " + << program_name + << " [-i input_file] [-o output_file] [-n iteration_count] [-r]\n"; + ACE_OS::exit (1); +} + +/* Clean up the output file on exit from a signal. */ + +static void +clean_up (int = 0) +{ + if (remove_output) + ACE_OS::unlink (output_filename); + ACE_OS::exit (0); +} + +/* Set up the program name used in error messages. */ + +static void +set_program_name (char name[]) +{ + if ((name = strrchr (name, '/')) == 0) + program_name = name; + else + program_name = name + 1; +} + +/* Parse the command-line arguments and set options. */ + +static void +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opt (argc, argv, "i:n:o:r"); + + for (int c; ((c = get_opt ()) != -1); ) + switch (c) + { + case 'i': + input_filename = get_opt.optarg; + break; + case 'n': + iteration_count = ACE_OS::atoi (get_opt.optarg); + break; + case 'o': + output_filename = get_opt.optarg; + break; + case 'r': + remove_output = 0; + break; + default: + print_usage_and_die (); + break; + } +} + +/* Vector of pointers to derived classes that inherit from IO_Test base class. */ + +static IO_Test *test_vector[100]; + +static void +run_tests (int iterations, FILE *input_fp, FILE *output_fp) +{ + // If HP/UX didn't suck so badly we could initialize in the global scope... + test_vector[0] = new Stdio_Test ("Stdio_Test", tm); + test_vector[1] = new Block_Fread_Fwrite_Test ("Block_Fread_Fwrite_Test", tm); + test_vector[2] = new Block_Read_Write_Test ("Block_Read_Write_Test", tm); + test_vector[3] = new Mmap1_Test ("Mmap1_Test", tm); + test_vector[4] = new Mmap2_Test ("Mmap2_Test", tm); + /* test_vector[5] = new Slow_Read_Write_Test ("Slow"Read_Write_Test", tm) */ + test_vector[5] = (IO_Test *) 0; + + for (int i = 0; test_vector[i] != 0; i++) + { + if (ACE_OS::ftruncate (fileno (output_fp), 0) == -1) + ::perror ("ftruncate"); + + cerr << "--------------------\n" + << "starting " << test_vector[i]->name () << " for " << iterations + << " iteration(s):\n"; + + if (test_vector[i]->run_test (iterations, input_fp, output_fp) == -1) + ::perror (test_vector[i]->name ()); + + ACE_Profile_Timer::ACE_Elapsed_Time et; + tm.elapsed_time (et); + + cerr << "wallclock time = " << et.real_time + << ", user time = " << et.user_time + << ", system time = " << et.system_time << endl; + + delete test_vector[i]; + } + + cerr << "--------------------\n"; +} + +int +main (int argc, char *argv[]) +{ + FILE *input_fp; + FILE *output_fp; + + set_program_name (argv[0]); + parse_args (argc, argv); + ACE_Sig_Action sig ((ACE_SignalHandler) clean_up, SIGINT); + + if ((input_fp = ACE_OS::fopen (input_filename, "r")) == 0) + ACE_OS::perror (input_filename), ACE_OS::exit (1); + + ACE_OS::unlink (output_filename); + + if ((output_fp = ACE_OS::fopen (output_filename, "w+")) == 0) + ACE_OS::perror (output_filename), ACE_OS::exit (1); + + run_tests (iteration_count, input_fp, output_fp); + + if (ACE_OS::fclose (input_fp) == -1 || ACE_OS::fclose (output_fp) == -1) + ACE_OS::perror ("fclose"), ACE_OS::exit (1); + + clean_up (); + return 0; +} diff --git a/examples/Mem_Map/Makefile b/examples/Mem_Map/Makefile new file mode 100644 index 00000000000..3c5d5f2d800 --- /dev/null +++ b/examples/Mem_Map/Makefile @@ -0,0 +1,22 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the Mem_Map test directory +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +DIRS = IO-tests \ + file-reverse + +#---------------------------------------------------------------------------- +# macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nolocal.GNU diff --git a/examples/Mem_Map/file-reverse/Makefile b/examples/Mem_Map/file-reverse/Makefile new file mode 100644 index 00000000000..ccc7ce66724 --- /dev/null +++ b/examples/Mem_Map/file-reverse/Makefile @@ -0,0 +1,58 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for Mem_Map file reverse test +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = file-reverse + +LSRC = $(addsuffix .cpp,$(BIN)) + +LDLIBS = + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +INSTALL = + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/file-reverse.o .shobj/file-reverse.so: file-reverse.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Mem_Map.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/Mem_Map/file-reverse/file-reverse.cpp b/examples/Mem_Map/file-reverse/file-reverse.cpp new file mode 100644 index 00000000000..d3431c40b0f --- /dev/null +++ b/examples/Mem_Map/file-reverse/file-reverse.cpp @@ -0,0 +1,45 @@ +#include "ace/Log_Msg.h" +// @(#)file-reverse.cpp 1.1 10/18/96 + +#include "ace/Mem_Map.h" + +static void +putline (const char *s) +{ + while (putchar (*s++) != '\n') + continue; +} + +static void +print_array_in_reverse (char *array, int size) +{ + size--; + + if (array[size] == '\0') + array[size] = '\n'; + + while (--size >= 0) + if (array[size] == '\n') + putline (array + size + 1); + + putline (array); +} + +int +main (int argc, char **argv) +{ + ACE_LOG_MSG->open (argv[0]); + void *cp; + + if (argc != 2) + ACE_ERROR_RETURN ((LM_ERROR, "usage: %n file\n%a"), -1); + + ACE_Mem_Map mmap; + + if (mmap.map (argv[1]) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%n: %p\n%a", "mmap"), -1); + + print_array_in_reverse ((char *) mmap.addr (), mmap.size ()); + + return 0; +} diff --git a/examples/Misc/Makefile b/examples/Misc/Makefile new file mode 100644 index 00000000000..8f950973535 --- /dev/null +++ b/examples/Misc/Makefile @@ -0,0 +1,283 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for testing the miscellaneous ACE components. +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = test_dump \ + test_profile_timer \ + test_read_buffer \ + test_sstring \ + test_trace \ + test_XtReactor1 \ + test_XtReactor2 + +LSRC = $(addsuffix .cpp,$(BIN)) + +LDLIBS = + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/test_dump.o .shobj/test_dump.so: test_dump.cpp \ + $(WRAPPER_ROOT)/ace/Dump.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Dump_T.h \ + $(WRAPPER_ROOT)/ace/Dump_T.cpp +.obj/test_profile_timer.o .shobj/test_profile_timer.so: test_profile_timer.cpp \ + $(WRAPPER_ROOT)/ace/Profile_Timer.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i +.obj/test_read_buffer.o .shobj/test_read_buffer.so: test_read_buffer.cpp \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Read_Buffer.h \ + $(WRAPPER_ROOT)/ace/Read_Buffer.i +.obj/test_sstring.o .shobj/test_sstring.so: test_sstring.cpp \ + $(WRAPPER_ROOT)/ace/SString.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i +.obj/test_trace.o .shobj/test_trace.so: test_trace.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i +.obj/test_XtReactor1.o .shobj/test_XtReactor1.so: test_XtReactor1.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/XtReactor.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h +.obj/test_XtReactor2.o .shobj/test_XtReactor2.so: test_XtReactor2.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/XtReactor.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/Misc/test_XtReactor1.cpp b/examples/Misc/test_XtReactor1.cpp new file mode 100644 index 00000000000..0204278a3e9 --- /dev/null +++ b/examples/Misc/test_XtReactor1.cpp @@ -0,0 +1,138 @@ +// The following is another test that exercises the Eric C. Newton's +// @(#)test_XtReactor1.cpp 1.1 10/18/96 + +// <ecn@clark.net> XtReactor implementation. + +#include "ace/Log_Msg.h" +#include "ace/XtReactor.h" +#include "ace/Message_Block.h" + +#if defined (ACE_HAS_XT) +#include <Xm/PushB.h> + +class Stdout : public ACE_Event_Handler +{ +public: + Stdout (ACE_Reactor * r) + : reactor_ (r), msg_ (1000000) + { + int flags; + flags = ACE_OS::fcntl (ACE_STDOUT, F_GETFL); + + if (flags != -1 + && ACE_OS::fcntl (ACE_STDOUT, F_SETFL, flags | O_NONBLOCK) != -1) + return; + else + ACE_DEBUG ((LM_DEBUG, "Unable to set stdout to non-block.")); + } + + ACE_HANDLE get_handle (void) const { return ACE_STDOUT; } + + int handle_output (ACE_HANDLE) + { + char *s = msg_.rd_ptr (); + + if (ACE_OS::write (ACE_STDOUT, s, 1)==1) + { + ACE_DEBUG ((LM_DEBUG, "wrote output '%d'\n", (int) *s)); + msg_.rd_ptr (1); + } + + if (msg_.length () == 0) + { + reactor_->remove_handler (this, ACE_Event_Handler::WRITE_MASK); + msg_.rd_ptr (msg_.base ()); + msg_.wr_ptr (msg_.base ()); + } + return 0; + } + + void put (char c) + { + if (msg_.length () == 0) + reactor_->register_handler (this, ACE_Event_Handler::WRITE_MASK); + + if (msg_.wr_ptr () < msg_.end ()) + { + *msg_.wr_ptr () = c; + msg_.wr_ptr (1); + } + else + ACE_DEBUG ((LM_DEBUG, "Oops... data falling off the end of the buffer!\n")); + } + +private: + ACE_Reactor *reactor_; + ACE_Message_Block msg_; +}; + +class Stdin : public ACE_Event_Handler +{ +public: + Stdin (Stdout *out) + : out_ (out) {} + + ACE_HANDLE get_handle () const { return ACE_STDIN; } + + int handle_input (ACE_HANDLE) + { + char c; + + if (ACE_OS::read (ACE_STDIN, &c, 1) == 1) + out_->put (c); + + return 0; + } + + int handle_timeout (const ACE_Time_Value &tv, const void *) + { + ACE_DEBUG ((LM_DEBUG, "Timeout! %f\n", (double) (tv.msec ()/1000.))); + return 0; + } + +private: + Stdout *out_; +}; + +static void +ActivateCB (Widget, XtPointer, XtPointer) +{ + ACE_DEBUG ((LM_DEBUG, "Button pushed!\n")); +} + +int +main (int argc, char**argv) +{ + // The worlds most useless user interface + Widget top_level = XtVaAppInitialize (NULL, "buttontest", NULL, 0, + &argc, argv, NULL, NULL); + Widget button = XmCreatePushButton (top_level, "change", 0, 0); + XtManageChild (button); + XtAddCallback (button, XmNactivateCallback, ActivateCB, NULL); + + // A reactor beastie + ACE_XtReactor reactor (XtWidgetToApplicationContext (top_level)); + + // Print a message when data is recv'd on stdin... + ACE_Event_Handler *stdin_ = new Stdin (new Stdout (&reactor)); + reactor.register_handler (stdin_, ACE_Event_Handler::READ_MASK); + + // Print a message every 10 seconds. + reactor.schedule_timer (stdin_, 0, ACE_Time_Value (10), ACE_Time_Value (10)); + + // Show the top_level widget. + XtRealizeWidget (top_level); + + // Demonstrate Reactor/Xt event loop unification. + XtAppMainLoop (XtWidgetToApplicationContext (top_level)); + + return 0; +} +#else +int +main (int, char *[]) +{ + ACE_ERROR ((LM_ERROR, "XT not configured for this platform\n")); + return 0; +} +#endif /* ACE_HAS_XT */ diff --git a/examples/Misc/test_XtReactor2.cpp b/examples/Misc/test_XtReactor2.cpp new file mode 100644 index 00000000000..31d43c6cab5 --- /dev/null +++ b/examples/Misc/test_XtReactor2.cpp @@ -0,0 +1,70 @@ +// The following test exercises the Eric C. Newton's <ecn@clark.net> +// @(#)test_XtReactor2.cpp 1.1 10/18/96 + +// XtReactor implementation. + +#include "ace/Log_Msg.h" +#include "ace/XtReactor.h" +#include "ace/Message_Block.h" + +#if defined (ACE_HAS_XT) +#include <Xm/PushB.h> + +class Stdin : public ACE_Event_Handler +{ +public: + ACE_HANDLE get_handle (void) const { return ACE_STDIN; } + + int handle_input (ACE_HANDLE fd) + { + char c; + if (read (0, &c, 1)==1) + printf ("Got input '%d'\n", (int)c); + return 0; + } + + int handle_timeout (const ACE_Time_Value &tv, const void *arg) + { + printf ("Timeout! %f\n", (double) (tv.msec ()/1000.)); + return 0; + } +}; + +void ActivateCB (Widget w, XtPointer, XtPointer) +{ + printf ("Button pushed!\n"); +} + +int main (int argc, char**argv) +{ + // The worlds most useless user interface + Widget top_level = XtVaAppInitialize (NULL, "buttontest", NULL, 0, + &argc, argv, NULL, NULL); + Widget button = XmCreatePushButton (top_level, "change", 0, 0); + XtManageChild (button); + XtAddCallback (button, XmNactivateCallback, ActivateCB, NULL); + + // A reactor beastie + XtReactor reactor (XtWidgetToApplicationContext (top_level)); + + // Print a message when data is recv'd on stdin... + ACE_Event_Handler * stdin_ = new Stdin; + reactor.register_handler (stdin_, ACE_Event_Handler::READ_MASK); + + // Print a message every 10 seconds + reactor.schedule_timer (stdin_, 0, ACE_Time_Value (10), ACE_Time_Value (10)); + + // Show the top_level widget + XtRealizeWidget (top_level); + + // Demonstrate Reactor/Xt event loop unification: + XtAppMainLoop (XtWidgetToApplicationContext (top_level)); +} +#else +int +main (int, char *[]) +{ + ACE_ERROR ((LM_ERROR, "XT not configured for this platform\n")); + return 0; +} +#endif /* ACE_HAS_XT */ diff --git a/examples/Misc/test_dump.cpp b/examples/Misc/test_dump.cpp new file mode 100644 index 00000000000..e76190b491a --- /dev/null +++ b/examples/Misc/test_dump.cpp @@ -0,0 +1,71 @@ +// The following code illustrates how the ACE_Dumpable mechanisms are +// @(#)test_dump.cpp 1.1 10/18/96 + +// integrated into ACE components like the SOCK_Acceptor and +// SOCK_Stream. + +#include "ace/Dump.h" + +class SOCK +{ +public: + SOCK (void) { ACE_REGISTER_OBJECT (SOCK); } + ~SOCK (void) { ACE_REMOVE_OBJECT; } + + void dump (void) const { + cerr << "hello from SOCK = " << (u_long) this << endl; + } + + // ... +}; + +class SOCK_Acceptor : public SOCK +{ +public: + SOCK_Acceptor (void) { ACE_REGISTER_OBJECT (SOCK_Acceptor); } + ~SOCK_Acceptor (void) { ACE_REMOVE_OBJECT; } + + void dump (void) const { + cerr << "hello from SOCK_Acceptor = " << (u_long) this << endl; + } + + // ... +}; + +class SOCK_Stream : public SOCK +{ +public: + SOCK_Stream (void) { ACE_REGISTER_OBJECT (SOCK_Stream); } + ~SOCK_Stream (void) { ACE_REMOVE_OBJECT; } + + void dump (void) const { + cerr << "hello from SOCK_Stream = " << (u_long) this << endl; + } + + // ... +}; + +int +main (void) +{ + SOCK sock; + // Note that the SOCK superclass is *not* printed. + SOCK_Stream stream; + SOCK_Acceptor acceptor; + ACE_ODB::instance ()->dump_objects (); + { + SOCK sock; + // Note that the SOCK superclass is *not* printed. + SOCK_Stream stream; + SOCK_Acceptor acceptor; + ACE_ODB::instance ()->dump_objects (); + } + ACE_ODB::instance ()->dump_objects (); + return 0; +} + +#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +template class ACE_Dumpable_Adapter<SOCK_Stream>; +template class ACE_Dumpable_Adapter<SOCK>; +template class ACE_Dumpable_Adapter<SOCK_Acceptor>; +#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ diff --git a/examples/Misc/test_profile_timer.cpp b/examples/Misc/test_profile_timer.cpp new file mode 100644 index 00000000000..5b888eb2362 --- /dev/null +++ b/examples/Misc/test_profile_timer.cpp @@ -0,0 +1,33 @@ +#include "ace/Profile_Timer.h" +// @(#)test_profile_timer.cpp 1.1 10/18/96 + +#include "ace/Log_Msg.h" + +static const int DEFAULT_ITERATIONS = 100000000; + +int +main (int argc, char *argv[]) +{ + ACE_Profile_Timer timer; + int iterations = argc > 1 ? ACE_OS::atoi (argv[1]) : DEFAULT_ITERATIONS; + + timer.start (); + + for (int i = 0; i < iterations; i++) + ACE_OS::getpid (); + + timer.stop (); + + ACE_Profile_Timer::ACE_Elapsed_Time et; + + timer.elapsed_time (et); + + ACE_DEBUG ((LM_DEBUG, "iterations = %d\n", iterations)); + ACE_DEBUG ((LM_DEBUG, "real time = %f secs, user time = %f secs, system time = %f secs\n", + et.real_time, et.user_time, et.system_time)); + + ACE_DEBUG ((LM_DEBUG, "time per call = %f usecs\n", + (et.real_time / double (iterations)) * 1000000)); + return 0; +} + diff --git a/examples/Misc/test_read_buffer.cpp b/examples/Misc/test_read_buffer.cpp new file mode 100644 index 00000000000..b7eb4947b3a --- /dev/null +++ b/examples/Misc/test_read_buffer.cpp @@ -0,0 +1,30 @@ +#include "ace/Service_Config.h" +// @(#)test_read_buffer.cpp 1.1 10/18/96 + +#include "ace/Read_Buffer.h" + +int +main (int argc, char *argv[]) +{ + int handle = argc > 1 ? ::open (argv[1], O_RDONLY) : 0; + int term = argc > 2 ? ::atoi (argv[2]) : EOF; + int search = argc > 3 ? ::atoi (argv[3]) : '\n'; + int replace = argc > 4 ? ::atoi (argv[4]) : '\0'; + + ACE_Read_Buffer rb (handle); + + char *buf; + + while ((buf = rb.read (term, search, replace)) != 0) + { + ::write (1, buf, rb.size ()); + ACE_Service_Config::allocator ()->free (buf); + } + return 0; +} + +#if 0 +#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +template class ACE_Stream<ACE_Null_Mutex, ACE_Null_Condition_Mutex>; +#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#endif diff --git a/examples/Misc/test_sstring.cpp b/examples/Misc/test_sstring.cpp new file mode 100644 index 00000000000..fb04760c724 --- /dev/null +++ b/examples/Misc/test_sstring.cpp @@ -0,0 +1,22 @@ +#include "ace/SString.h" +// @(#)test_sstring.cpp 1.1 10/18/96 + + +int +main (int argc, char *argv[]) +{ + ACE_CString s1 ("hello"); + ACE_CString s2 ("world"); + ACE_CString s3 ("el"); + ACE_WString s4 ("hello"); + ACE_WString s5 ("world"); + ACE_WString s6 ("el"); + + ACE_ASSERT (s1 != s2); + ACE_ASSERT (s1.strstr (s2) == -1); + ACE_ASSERT (s1.strstr (s2) == -1); + ACE_ASSERT (s1.strstr (s3)); + ACE_ASSERT (s4.strstr (s5) == -1); + ACE_ASSERT (s5.strstr (s6)); + return 0; +} diff --git a/examples/Misc/test_trace.cpp b/examples/Misc/test_trace.cpp new file mode 100644 index 00000000000..e452140f665 --- /dev/null +++ b/examples/Misc/test_trace.cpp @@ -0,0 +1,52 @@ +// Enable tracing +// @(#)test_trace.cpp 1.1 10/18/96 + +#define ACE_NTRACE 0 +#include "ace/Log_Msg.h" + +#if defined (ACE_MT_SAFE) +#include "ace/Thread.h" +#endif /* ACE_MT_SAFE */ + +#include "ace/Signal.h" + +static void +foo (int max_depth) +{ + ACE_Trace _ ("void foo (void)", __LINE__, __FILE__); + + if (max_depth > 0) + foo (max_depth - 1); + /* Destructor automatically called */ +} + +int +main (int argc, char *argv[]) +{ + const int MAX_DEPTH = argc == 1 ? 10 : atoi (argv[1]); + + if (argc > 2) + ACE_Trace::set_nesting_indent (ACE_OS::atoi (argv[2])); + + ACE_Trace _ ("int main (int argc, char *argv[])", __LINE__, __FILE__); + + ACE_Sig_Action sig1 ((ACE_SignalHandler) ACE_Trace::start_tracing, SIGUSR1); + ACE_Sig_Action sig2 ((ACE_SignalHandler) ACE_Trace::stop_tracing, SIGUSR2); + +#if defined (ACE_MT_SAFE) + int n_threads = argc > 3 ? ACE_OS::atoi (argv[3]) : 4; + + if (ACE_Thread::spawn_n (n_threads, ACE_THR_FUNC (foo), + (void *) MAX_DEPTH, + THR_BOUND | THR_DETACHED) != n_threads) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn_n"), -1); + ACE_OS::thr_exit (0); +#else + for (;;) + foo (MAX_DEPTH); +#endif /* ACE_MT_SAFE */ + + /* Destructor automatically called */ + return 0; +} + diff --git a/examples/OS/Makefile b/examples/OS/Makefile new file mode 100644 index 00000000000..57607591fea --- /dev/null +++ b/examples/OS/Makefile @@ -0,0 +1,21 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the OS class examples +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +DIRS = Process + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nolocal.GNU diff --git a/examples/OS/Process/Makefile b/examples/OS/Process/Makefile new file mode 100644 index 00000000000..a4113d16997 --- /dev/null +++ b/examples/OS/Process/Makefile @@ -0,0 +1,47 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for repeating token client application +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = process + +FILES = process + +LSRC = $(addsuffix .cpp,$(FILES)) +LOBJ = $(LSRC:%.cpp=$(VDIR)%.o) +SHOBJ = $(addsuffix .so,$(FILES)) + +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.lib.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + + + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/OS/Process/Process.mak b/examples/OS/Process/Process.mak new file mode 100644 index 00000000000..bf99fd864af --- /dev/null +++ b/examples/OS/Process/Process.mak @@ -0,0 +1,311 @@ +# Microsoft Developer Studio Generated NMAKE File, Format Version 4.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+!IF "$(CFG)" == ""
+CFG=Process - Win32 Debug
+!MESSAGE No configuration specified. Defaulting to Process - Win32 Debug.
+!ENDIF
+
+!IF "$(CFG)" != "Process - Win32 Release" && "$(CFG)" !=\
+ "Process - Win32 Debug"
+!MESSAGE Invalid configuration "$(CFG)" specified.
+!MESSAGE You can specify a configuration when running NMAKE on this makefile
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "Process.mak" CFG="Process - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "Process - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "Process - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+!ERROR An invalid configuration is specified.
+!ENDIF
+
+!IF "$(OS)" == "Windows_NT"
+NULL=
+!ELSE
+NULL=nul
+!ENDIF
+################################################################################
+# Begin Project
+RSC=rc.exe
+CPP=cl.exe
+
+!IF "$(CFG)" == "Process - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+OUTDIR=.\Release
+INTDIR=.\Release
+
+ALL : "$(OUTDIR)\Process.exe"
+
+CLEAN :
+ -@erase ".\Release\Process.exe"
+ -@erase ".\Release\process.obj"
+
+"$(OUTDIR)" :
+ if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
+# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
+CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\
+ /Fp"$(INTDIR)/Process.pch" /YX /Fo"$(INTDIR)/" /c
+CPP_OBJS=.\Release/
+CPP_SBRS=
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+BSC32_FLAGS=/nologo /o"$(OUTDIR)/Process.bsc"
+BSC32_SBRS=
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib ace.lib /nologo /subsystem:console /machine:I386
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
+ advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib ace.lib /nologo\
+ /subsystem:console /incremental:no /pdb:"$(OUTDIR)/Process.pdb" /machine:I386\
+ /out:"$(OUTDIR)/Process.exe"
+LINK32_OBJS= \
+ "$(INTDIR)/process.obj"
+
+"$(OUTDIR)\Process.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ELSEIF "$(CFG)" == "Process - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+OUTDIR=.
+INTDIR=.\Debug
+
+ALL : "$(OUTDIR)\Process.exe"
+
+CLEAN :
+ -@erase ".\Debug\vc40.pdb"
+ -@erase ".\Debug\vc40.idb"
+ -@erase ".\Process.exe"
+ -@erase ".\Debug\process.obj"
+ -@erase ".\Process.ilk"
+ -@erase ".\Process.pdb"
+
+"$(INTDIR)" :
+ if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
+
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
+# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
+CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE"\
+ /Fp"$(INTDIR)/Process.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
+CPP_OBJS=.\Debug/
+CPP_SBRS=
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+BSC32_FLAGS=/nologo /o"$(OUTDIR)/Process.bsc"
+BSC32_SBRS=
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:console /debug /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib ace.lib /nologo /subsystem:console /debug /machine:I386
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
+ advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib ace.lib /nologo\
+ /subsystem:console /incremental:yes /pdb:"$(OUTDIR)/Process.pdb" /debug\
+ /machine:I386 /out:"$(OUTDIR)/Process.exe"
+LINK32_OBJS= \
+ "$(INTDIR)/process.obj"
+
+"$(OUTDIR)\Process.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ENDIF
+
+.c{$(CPP_OBJS)}.obj:
+ $(CPP) $(CPP_PROJ) $<
+
+.cpp{$(CPP_OBJS)}.obj:
+ $(CPP) $(CPP_PROJ) $<
+
+.cxx{$(CPP_OBJS)}.obj:
+ $(CPP) $(CPP_PROJ) $<
+
+.c{$(CPP_SBRS)}.sbr:
+ $(CPP) $(CPP_PROJ) $<
+
+.cpp{$(CPP_SBRS)}.sbr:
+ $(CPP) $(CPP_PROJ) $<
+
+.cxx{$(CPP_SBRS)}.sbr:
+ $(CPP) $(CPP_PROJ) $<
+
+################################################################################
+# Begin Target
+
+# Name "Process - Win32 Release"
+# Name "Process - Win32 Debug"
+
+!IF "$(CFG)" == "Process - Win32 Release"
+
+!ELSEIF "$(CFG)" == "Process - Win32 Debug"
+
+!ENDIF
+
+################################################################################
+# Begin Source File
+
+SOURCE=.\process.cpp
+DEP_CPP_PROCE=\
+ {$(INCLUDE)}"\ace\OS.h"\
+ {$(INCLUDE)}"\ace\Log_Msg.h"\
+ {$(INCLUDE)}"\ace\Process.h"\
+ {$(INCLUDE)}"\ace\Time_Value.h"\
+ {$(INCLUDE)}"\sys\types.h"\
+ {$(INCLUDE)}"\sys\stat.h"\
+ {$(INCLUDE)}"\sys\timeb.h"\
+ {$(INCLUDE)}"\ace\msg_hack.h"\
+ {$(INCLUDE)}"\ace\Trace.h"\
+ {$(INCLUDE)}"\ace\OS.i"\
+ {$(INCLUDE)}"\ace\config.h"\
+ {$(INCLUDE)}"\ace\Time_Value.i"\
+ {$(INCLUDE)}"\ace\Log_Record.h"\
+ {$(INCLUDE)}"\ace\ACE.h"\
+ {$(INCLUDE)}"\ace\Log_Priority.h"\
+ {$(INCLUDE)}"\ace\Log_Record.i"\
+ {$(INCLUDE)}"\ace\ACE.i"\
+ {$(INCLUDE)}"\ace\ARGV.h"\
+ {$(INCLUDE)}"\ace\Mem_Map.h"\
+ {$(INCLUDE)}"\ace\Svc_Handler.h"\
+ {$(INCLUDE)}"\ace\Synch.h"\
+ {$(INCLUDE)}"\ace\Acceptor.h"\
+ {$(INCLUDE)}"\ace\SOCK_Acceptor.h"\
+ {$(INCLUDE)}"\ace\Process.i"\
+ {$(INCLUDE)}"\ace\ARGV.i"\
+ {$(INCLUDE)}"\ace\Mem_Map.i"\
+ {$(INCLUDE)}"\ace\Synch_Options.h"\
+ {$(INCLUDE)}"\ace\Task.h"\
+ {$(INCLUDE)}"\ace\Service_Config.h"\
+ {$(INCLUDE)}"\ace\Synch_T.h"\
+ {$(INCLUDE)}"\ace\Svc_Handler.i"\
+ {$(INCLUDE)}"\ace\Svc_Handler.cpp"\
+ {$(INCLUDE)}"\ace\Service_Object.h"\
+ {$(INCLUDE)}"\ace\Message_Queue.h"\
+ {$(INCLUDE)}"\ace\Thread_Manager.h"\
+ {$(INCLUDE)}"\ace\Task.i"\
+ {$(INCLUDE)}"\ace\Task.cpp"\
+ {$(INCLUDE)}"\ace\Shared_Object.h"\
+ {$(INCLUDE)}"\ace\Event_Handler.h"\
+ {$(INCLUDE)}"\ace\Service_Object.i"\
+ {$(INCLUDE)}"\ace\Shared_Object.i"\
+ {$(INCLUDE)}"\ace\Event_Handler.i"\
+ {$(INCLUDE)}"\ace\Message_Block.h"\
+ {$(INCLUDE)}"\ace\IO_Cntl_Msg.h"\
+ {$(INCLUDE)}"\ace\Message_Queue.i"\
+ {$(INCLUDE)}"\ace\Message_Queue.cpp"\
+ {$(INCLUDE)}"\ace\Malloc.h"\
+ {$(INCLUDE)}"\ace\Message_Block.i"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Simple.h"\
+ {$(INCLUDE)}"\ace\Malloc.i"\
+ {$(INCLUDE)}"\ace\Malloc_T.h"\
+ {$(INCLUDE)}"\ace\Memory_Pool.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Simple.i"\
+ {$(INCLUDE)}"\ace\Malloc_T.i"\
+ {$(INCLUDE)}"\ace\Malloc_T.cpp"\
+ {$(INCLUDE)}"\ace\Signal.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Complex.h"\
+ {$(INCLUDE)}"\ace\Memory_Pool.i"\
+ {$(INCLUDE)}"\ace\Set.h"\
+ {$(INCLUDE)}"\ace\Signal.i"\
+ {$(INCLUDE)}"\ace\Set.i"\
+ {$(INCLUDE)}"\ace\Set.cpp"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Complex.i"\
+ {$(INCLUDE)}"\ace\Thread.h"\
+ {$(INCLUDE)}"\ace\Thread_Manager.i"\
+ {$(INCLUDE)}"\ace\Thread.i"\
+ {$(INCLUDE)}"\ace\Module.h"\
+ {$(INCLUDE)}"\ace\Module.i"\
+ {$(INCLUDE)}"\ace\Module.cpp"\
+ {$(INCLUDE)}"\ace\Stream_Modules.h"\
+ {$(INCLUDE)}"\ace\Stream_Modules.i"\
+ {$(INCLUDE)}"\ace\Stream_Modules.cpp"\
+ {$(INCLUDE)}"\ace\Proactor.h"\
+ {$(INCLUDE)}"\ace\ReactorEx.h"\
+ {$(INCLUDE)}"\ace\Service_Config.i"\
+ {$(INCLUDE)}"\ace\Reactor.h"\
+ {$(INCLUDE)}"\ace\Svc_Conf_Tokens.h"\
+ {$(INCLUDE)}"\ace\Timer_Queue.h"\
+ {$(INCLUDE)}"\ace\Proactor.i"\
+ {$(INCLUDE)}"\ace\Timer_Queue.i"\
+ {$(INCLUDE)}"\ace\Token.h"\
+ {$(INCLUDE)}"\ace\Local_Tokens.h"\
+ {$(INCLUDE)}"\ace\ReactorEx.i"\
+ {$(INCLUDE)}"\ace\Token.i"\
+ {$(INCLUDE)}"\ace\Stack.h"\
+ {$(INCLUDE)}"\ace\Map_Manager.h"\
+ {$(INCLUDE)}"\ace\Local_Tokens.i"\
+ {$(INCLUDE)}"\ace\Stack.i"\
+ {$(INCLUDE)}"\ace\Stack.cpp"\
+ {$(INCLUDE)}"\ace\Map_Manager.i"\
+ {$(INCLUDE)}"\ace\Map_Manager.cpp"\
+ {$(INCLUDE)}"\ace\Handle_Set.h"\
+ {$(INCLUDE)}"\ace\Pipe.h"\
+ {$(INCLUDE)}"\ace\SOCK_Stream.h"\
+ {$(INCLUDE)}"\ace\Reactor.i"\
+ {$(INCLUDE)}"\ace\Handle_Set.i"\
+ {$(INCLUDE)}"\ace\Pipe.i"\
+ {$(INCLUDE)}"\ace\SOCK_IO.h"\
+ {$(INCLUDE)}"\ace\INET_Addr.h"\
+ {$(INCLUDE)}"\ace\SOCK_Stream.i"\
+ {$(INCLUDE)}"\ace\SOCK.h"\
+ {$(INCLUDE)}"\ace\SOCK_IO.i"\
+ {$(INCLUDE)}"\ace\Addr.h"\
+ {$(INCLUDE)}"\ace\IPC_SAP.h"\
+ {$(INCLUDE)}"\ace\SOCK.i"\
+ {$(INCLUDE)}"\ace\Addr.i"\
+ {$(INCLUDE)}"\ace\IPC_SAP.i"\
+ {$(INCLUDE)}"\ace\INET_Addr.i"\
+ {$(INCLUDE)}"\ace\Synch_T.i"\
+ {$(INCLUDE)}"\ace\Synch_T.cpp"\
+ {$(INCLUDE)}"\ace\Dynamic.h"\
+ {$(INCLUDE)}"\ace\Dynamic.i"\
+ {$(INCLUDE)}"\ace\Synch.i"\
+ {$(INCLUDE)}"\ace\Strategies.h"\
+ {$(INCLUDE)}"\ace\Acceptor.i"\
+ {$(INCLUDE)}"\ace\Acceptor.cpp"\
+ {$(INCLUDE)}"\ace\Strategies.cpp"\
+ {$(INCLUDE)}"\ace\SOCK_Acceptor.i"\
+
+NODEP_CPP_PROCE=\
+ "..\..\ACE_wrappers\ace\ace\Sync_T.h"\
+
+
+"$(INTDIR)\process.obj" : $(SOURCE) $(DEP_CPP_PROCE) "$(INTDIR)"
+
+
+# End Source File
+# End Target
+# End Project
+################################################################################
diff --git a/examples/OS/Process/Process.mdp b/examples/OS/Process/Process.mdp Binary files differnew file mode 100644 index 00000000000..dba659ad56d --- /dev/null +++ b/examples/OS/Process/Process.mdp diff --git a/examples/OS/Process/README b/examples/OS/Process/README new file mode 100644 index 00000000000..2c2c801d5df --- /dev/null +++ b/examples/OS/Process/README @@ -0,0 +1,10 @@ +This example shows how to use ACE_Process to "portably" create new +processes and set their standard handles (stdin, stdout, and stderr). +On UNIX, ACE_Process uses fork and exec. On Win32, it uses +CreateProcess. Since we can set the standard handles, we can mimic +UNIX pipes on Win32 by building chains of processes. + +Run the application by typing ./process [filename]. It creates a new +process to print the contents of <filename> (default is the name of +the file "process.cpp") to the main console. So all you should see is +process.cpp printed to the screen. Not very exciting... diff --git a/examples/OS/Process/process.cpp b/examples/OS/Process/process.cpp new file mode 100644 index 00000000000..56979c31cd4 --- /dev/null +++ b/examples/OS/Process/process.cpp @@ -0,0 +1,64 @@ +// ============================================================================ +// @(#)process.cpp 1.1 10/18/96 + +// +// = LIBRARY +// examples +// +// = FILENAME +// process.cpp +// +// = DESCRIPTION +// This example tests the ACE_Process. For more info, check the +// README file in this directory. +// +// = AUTHOR +// Tim Harrison. +// +// ============================================================================ + +#include "ace/OS.h" +#include "ace/Log_Msg.h" +#include "ace/Process.h" + +#if defined (ACE_WIN32) +#define EXEC_NAME "c:\\WINNT35\\system32\\MORE.COM" +#else +#define EXEC_NAME "/usr/bin/cat"; +#endif /* ACE_WIN32 */ + +int +main (int argc, char *argv[]) +{ + if (ACE_LOG_MSG->open (argv[0]) == -1) + ACE_ERROR ((LM_ERROR, "cannot open logger!!!\n")); + + char *executable = argc > 1 ? argv[1] : EXEC_NAME; + char *input_file = argc > 2 ? argv[2] : "process.cpp"; + + ACE_HANDLE infile = ACE_OS::open (input_file, O_RDONLY); + + if (infile == ACE_INVALID_HANDLE) + ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", input_file), 1); + + static char *l_argv[2]; // Starts out with 0's ;-) + l_argv[0] = executable; + + // Try to create a new process running the <executable>. + ACE_Process new_process (l_argv, infile); + + if (ACE_LOG_MSG->op_status () == -1) + { + int error = ACE_OS::last_error (); + ACE_ERROR ((LM_ERROR, "%p errno = %d.\n", + executable, error)); + } + + new_process.wait (); + ACE_OS::close (infile); + + ACE_DEBUG ((LM_DEBUG, "Goodbye.\n")); + return 42; +} + + diff --git a/examples/README b/examples/README new file mode 100644 index 00000000000..38bb99b7d1d --- /dev/null +++ b/examples/README @@ -0,0 +1,74 @@ +This directory contains a number of examples that illustrate how to +use the following ACE library components. If you want to see how +to program using ACE, this is the best place to start reading code and +learning the ACE design. + +These examples are roughly divided up according to the class +categories in ACE. For more information on ACE class categories, +please take a look at $WRAPPER_ROOT/ACE-categories. + + . ASX + Illustrate various components in the ADAPTIVE Service + eXecutive, which is a user-level implementation of + System V STREAMS written in C++. + + + . CORBA + Illustrate how CORBA can be integrated into ACE. + + . Connection + Illustrate how the various Acceptor and Connector + components can be used. + + . IPC_SAP + Illustrate the C++ wrappers for Sockets, TLI, UNIX and + Win32 Named Pipes, and UNIX Stream Pipes. + + . Log_Msg + Illustrate some of the features of the logging + facility used in ACE to consolidate debugging and + error report. + + . Logger + This is a simple version of a Server Logging Daemon + that illustrates the "bare-bones" usage of the + Reactor. A more sophisticated set of logging examples + are in the $WRAPPER_ROOT/netsvcs/{client,lib,server} + directories. + + . Mem_Map + Illustrate how the ACE memory-mapped file components + work. + + . Misc + Various miscellaneous tests that illustrate how ACE + utility components work. + + . Reactor + Contains many examples of how to utilize the ACE + object-oriented event demultiplexer. + + . Service_Configurator + Illustrates the use of the ACE mechanism for + dynamically configuring communication services. + + . Shared_Malloc + Illustrates the use of ACE wrappers for + sophisticated use of the ACE_Malloc shared + memory components. + + . Shared_Memory + Illustrates the use of simple ACE wrappers for + shared memory and memory mapped file. + + . System_V_IPC + Illustrates how to use the ACE wrappers for System V + IPC (i.e., semphores, shared memory, and message + queues). + + . Threads + Illustrates the use of ACE wrappers for threading + and synchronization. + + + diff --git a/examples/Reactor/Dgram/CODgram.cpp b/examples/Reactor/Dgram/CODgram.cpp new file mode 100644 index 00000000000..8856e92d3c5 --- /dev/null +++ b/examples/Reactor/Dgram/CODgram.cpp @@ -0,0 +1,121 @@ +/* Exercise the ACE_SOCK_CODgram wrapper along with the ACE_Reactor. +// @(#)CODgram.cpp 1.1 10/18/96 + + + Typical invocation sequence is: + + % CODgram 10000 localhost 10001 & + % CODgram 10001 localhost 10000 + + This will start two interacting copies of the CODgram + application. */ + +#include "ace/Reactor.h" +#include "ace/SOCK_CODgram.h" +#include "ace/INET_Addr.h" + +class AAL_CP : public ACE_Event_Handler, public ACE_SOCK_CODgram +{ +public: + AAL_CP (const ACE_INET_Addr &remote_addr, + const ACE_INET_Addr &local_addr); + + virtual int get_handle () const; + + virtual int handle_input (int fd); + + virtual int handle_timeout (const ACE_Time_Value & tv, + const void *arg = 0); +}; + +AAL_CP::AAL_CP (const ACE_INET_Addr &remote_addr, + const ACE_INET_Addr &local_addr) + : ACE_SOCK_CODgram (remote_addr, local_addr) +{ +} + +int +AAL_CP::get_handle () const +{ + return ACE_SOCK_CODgram::get_handle (); +} + +int +AAL_CP::handle_input (int) +{ + char buf[128]; + int n; + ACE_DEBUG ((LM_DEBUG, "Activity occurred on handle %d!\n", + ACE_SOCK_CODgram::get_handle ())); + if ((n = ACE_SOCK_CODgram::recv (buf, sizeof buf)) == -1) + ACE_ERROR ((LM_ERROR, "%p\n", "handle_input")); + else + ACE_DEBUG ((LM_DEBUG, "got buf = %s\n", buf)); + + return 0; +} + +int +AAL_CP::handle_timeout (const ACE_Time_Value &, const void *) +{ + ACE_DEBUG ((LM_DEBUG, "timed out for aa1\n")); + return 0; +} + +main(int argc, char *argv[]) +{ + /* Estabish call backs, and socket names */ + if (argc != 4) + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s localport remotehost remoteport\n", + argv[0]), -1); + + ACE_Reactor reactor; + char buf[128]; + u_short localport = ACE_OS::atoi (argv[1]); + u_short remoteport = ACE_OS::atoi (argv[3]); + char *remotehost = argv[2]; + + ACE_INET_Addr remote_addr (remoteport, remotehost); + ACE_INET_Addr local_addr (localport); + + AAL_CP aal (remote_addr, local_addr); + + if (localport == 10000) // HACK + { + ACE_OS::memcpy (buf, "Data to transmit", sizeof buf); + ACE_DEBUG ((LM_DEBUG, "sending data\n")); + + for (int i = 0; i < 20; i++) + { + aal.send (buf, sizeof buf); + ACE_DEBUG ((LM_DEBUG, ".\n")); + ACE_OS::sleep (1); + } + } + + /* read data from other side */ + if (reactor.register_handler (&aal, ACE_Event_Handler::READ_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "ACE_Reactor::register_handler"), -1); + + if (reactor.schedule_timer (&aal, 0, + ACE_Time_Value (1, 0), + ACE_Time_Value (0, 3500000)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "ACE_Reactor::schedule_timer"), -1); + + ACE_OS::memcpy (buf, "Data to transmit", sizeof buf); + + for (;;) + { + /* Wait at most two seconds */ + ACE_Time_Value tv (2, 0); + + reactor.handle_events (tv); + + ACE_DEBUG ((LM_DEBUG, "return from handle events\n")); + aal.send (buf, sizeof buf); + ACE_DEBUG ((LM_DEBUG, ".\n")); + } + + return 0; +} diff --git a/examples/Reactor/Dgram/Dgram.cpp b/examples/Reactor/Dgram/Dgram.cpp new file mode 100644 index 00000000000..d2f4305f267 --- /dev/null +++ b/examples/Reactor/Dgram/Dgram.cpp @@ -0,0 +1,121 @@ +// Exercise the ACE_SOCK_Dgram wrapper along with the ACE_Reactor. +// @(#)Dgram.cpp 1.1 10/18/96 + +// Typical invocation sequence is: +// +// % Dgram 10000 localhost 10001 & +// % Dgram 10001 localhost 10000 +// +// This will start two interacting copies of the Dgram +// application. + +#include "ace/Reactor.h" +#include "ace/SOCK_Dgram.h" +#include "ace/INET_Addr.h" + +class AAL_CP : public ACE_Event_Handler, public ACE_SOCK_Dgram +{ +public: + AAL_CP (const ACE_INET_Addr &local_addr); + + virtual ACE_HANDLE get_handle (void) const; + + virtual int handle_input (ACE_HANDLE handle); + + virtual int handle_timeout (const ACE_Time_Value & tv, + const void *arg = 0); +}; + +AAL_CP::AAL_CP (const ACE_INET_Addr &local_addr) + : ACE_SOCK_Dgram (local_addr) +{ +} + +ACE_HANDLE +AAL_CP::get_handle (void) const +{ + return ACE_SOCK_Dgram::get_handle (); +} + +int +AAL_CP::handle_input (ACE_HANDLE) +{ + char buf[BUFSIZ]; + int n; + ACE_INET_Addr from_addr; + + ACE_DEBUG ((LM_DEBUG, "Activity occurred on handle %d!\n", + ACE_SOCK_Dgram::get_handle ())); + if ((n = ACE_SOCK_Dgram::recv (buf, sizeof buf, from_addr)) == -1) + ACE_ERROR ((LM_ERROR, "%p\n", "handle_input")); + else + ACE_DEBUG ((LM_DEBUG, "got buf = %s\n", buf)); + + return 0; +} + +int +AAL_CP::handle_timeout (const ACE_Time_Value &, const void *) +{ + ACE_DEBUG ((LM_DEBUG, "timed out for aa1\n")); + return 0; +} + +int +main (int argc, char *argv[]) +{ + // Estabish call backs, and socket names. + if (argc != 4) + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s localport remotehost remoteport\n", + argv[0]), -1); + + ACE_Reactor reactor; + char buf[128]; + u_short localport = ACE_OS::atoi (argv[1]); + u_short remoteport = ACE_OS::atoi (argv[3]); + char *remotehost = argv[2]; + + ACE_INET_Addr remote_addr (remoteport, remotehost); + ACE_INET_Addr local_addr (localport); + + AAL_CP aal (local_addr); + + if (localport == 10000) // HACK + { + ACE_OS::memcpy (buf, "Data to transmit", sizeof buf); + ACE_DEBUG ((LM_DEBUG, "sending data\n")); + + for (size_t i = 0; i < 20; i++) + { + aal.send (buf, sizeof buf, remote_addr); + ACE_DEBUG ((LM_DEBUG, ".\n")); + ACE_OS::sleep (1); + } + } + + // Read data from other side. + if (reactor.register_handler (&aal, ACE_Event_Handler::READ_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "ACE_Reactor::register_handler"), -1); + + if (reactor.schedule_timer (&aal, 0, + ACE_Time_Value (1, 0), + ACE_Time_Value (0, 3500000)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "ACE_Reactor::schedule_timer"), -1); + + ACE_OS::memcpy (buf, "Data to transmit", sizeof buf); + + for (;;) + { + // Wait at most two seconds. + ACE_Time_Value tv (2, 0); + + reactor.handle_events (tv); + + ACE_DEBUG ((LM_DEBUG, "return from handle events\n")); + aal.send (buf, sizeof buf, remote_addr); + ACE_DEBUG ((LM_DEBUG, ".\n")); + } + + return 0; +} diff --git a/examples/Reactor/Dgram/Makefile b/examples/Reactor/Dgram/Makefile new file mode 100644 index 00000000000..5c2204cd91a --- /dev/null +++ b/examples/Reactor/Dgram/Makefile @@ -0,0 +1,135 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for a test of the CODgram and Dgram facilities and the Reactor +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = CODgram Dgram + +LSRC = CODgram.cpp Dgram.cpp + +LDLIBS = + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +INSTALL = + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/CODgram.o .shobj/CODgram.so: CODgram.cpp \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/SOCK_CODgram.h \ + $(WRAPPER_ROOT)/ace/SOCK_CODgram.i +.obj/Dgram.o .shobj/Dgram.so: Dgram.cpp \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/SOCK_Dgram.h \ + $(WRAPPER_ROOT)/ace/SOCK_Dgram.i + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/Reactor/Makefile b/examples/Reactor/Makefile new file mode 100644 index 00000000000..4613709a2a2 --- /dev/null +++ b/examples/Reactor/Makefile @@ -0,0 +1,24 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the Reactor tests +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +DIRS = Dgram \ + Misc \ + Multicast \ + Ntalker + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nolocal.GNU diff --git a/examples/Reactor/Misc/Makefile b/examples/Reactor/Misc/Makefile new file mode 100644 index 00000000000..31d49795de7 --- /dev/null +++ b/examples/Reactor/Misc/Makefile @@ -0,0 +1,378 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for a test of the miscellaneous Reactor examples +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = pingpong \ + notification \ + signal_tester \ + test_event_handler_t \ + test_handle_set \ + test_reactors \ + test_signals \ + test_time_value \ + test_timer_queue + +LSRC = $(addsuffix .cpp,$(BIN)) + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/pingpong.o .shobj/pingpong.so: pingpong.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i +.obj/notification.o .shobj/notification.so: notification.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h +.obj/signal_tester.o .shobj/signal_tester.so: signal_tester.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h +.obj/test_event_handler_t.o .shobj/test_event_handler_t.so: test_event_handler_t.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Event_Handler_T.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h +.obj/test_handle_set.o .shobj/test_handle_set.so: test_handle_set.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Handle_Set.h +.obj/test_reactors.o .shobj/test_reactors.so: test_reactors.cpp \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Task.i +.obj/test_signals.o .shobj/test_signals.so: test_signals.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i +.obj/test_time_value.o .shobj/test_time_value.so: test_time_value.cpp \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i +.obj/test_timer_queue.o .shobj/test_timer_queue.so: test_timer_queue.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/Reactor/Misc/notification.cpp b/examples/Reactor/Misc/notification.cpp new file mode 100644 index 00000000000..45836446b5a --- /dev/null +++ b/examples/Reactor/Misc/notification.cpp @@ -0,0 +1,249 @@ +#include "ace/Log_Msg.h" +// @(#)notification.cpp 1.1 10/18/96 + +#include "ace/Service_Config.h" +#include "ace/Thread.h" + +#if defined (ACE_HAS_THREADS) + +class Thread_Handler : public ACE_Event_Handler + // = TITLE + // Illustrate how the ACE_Reactor's thread-safe event notification + // mechanism works. + // + // = DESCRIPTION + // Handle timeouts in the main thread via the ACE_Reactor and I/O + // events in a separate thread. Just before the separate I/O thread + // exits it notifies the ACE_Reactor in the main thread using the + // ACE_Reactor's notification mechanism. +{ +public: + Thread_Handler (int delay, int interval, int n_threads); + Thread_Handler (size_t id): id_ (id) {} + + virtual int handle_signal (int signum, siginfo_t * = 0, ucontext_t * = 0); + // Handle signals. + + virtual int handle_exception (ACE_HANDLE); + // Print data from main thread. + + virtual int handle_output (ACE_HANDLE); + // Print data from main thread. + + virtual int handle_timeout (const ACE_Time_Value &, + const void *); + // Handle timeout events in the main thread. + + virtual int handle_input (ACE_HANDLE); + // General notification messages to the Reactor. + + virtual int notify (void); + // Perform notifications. + + virtual int svc (void); + // Handle I/O events in a separate threads. + +private: + static void *svc_run (void *); + // Glues C++ to C thread library functions. + + size_t id_; + // ID passed in by Thread_Handler constructor. + + // = Timing variables. + // Delay factor for timer-driven I/O. + static ACE_Time_Value delay_; + + // Interval factor for Event_Handler timer. + static ACE_Time_Value interval_; +}; + +// Delay factor for timer-driven I/O. +ACE_Time_Value Thread_Handler::delay_; + +// Interval factor for Event_Handler timer. +ACE_Time_Value Thread_Handler::interval_; + +Thread_Handler::Thread_Handler (int delay, + int interval, + int n_threads) +{ + delay_.set (delay); + interval_.set (interval); + + ACE_Sig_Set sig_set; + + sig_set.sig_add (SIGQUIT); + sig_set.sig_add (SIGINT); + + this->id_ = 0; + + 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")); + + else if (ACE_Service_Config::reactor ()->register_handler (sig_set, this) == -1) + ACE_ERROR ((LM_ERROR, "(%t) %p\n", "register_handler")); + + else if (ACE_Service_Config::reactor ()->schedule_timer + (this, 0, Thread_Handler::delay_, Thread_Handler::interval_) == -1) + ACE_ERROR ((LM_ERROR, "(%t) %p\n", "schedule_timer")); + + // Set up this thread's signal mask, which is inherited by the + // threads it spawns. + + ACE_Thread::sigsetmask (SIG_BLOCK, sig_set); + + // Create N new threads of control Thread_Handlers. + + for (size_t i = 0; i < n_threads; i++) + if (ACE_Thread::spawn (&Thread_Handler::svc_run, + new Thread_Handler (i + 1), + THR_NEW_LWP | THR_DETACHED) != 0) + ACE_ERROR ((LM_ERROR, "%p\n", "ACE_Thread::spawn")); + + // Unblock signal set so that only this thread receives them! + ACE_Thread::sigsetmask (SIG_UNBLOCK, sig_set); +} + +// Test stdin handling (can use select to demultiplex HANDLEs) + +int +Thread_Handler::handle_input (ACE_HANDLE handle) +{ + char buf[BUFSIZ]; + ssize_t n = ACE_OS::read (handle, buf, sizeof buf); + + if (n > 0) + { + ACE_DEBUG ((LM_DEBUG, "(%t) %*s", n, buf)); + return this->notify (); + } + else + return -1; +} + +int +Thread_Handler::notify (void) +{ + // Just do something to test the ACE_Reactor's multi-thread + // capabilities... + + if (ACE_Service_Config::reactor ()->notify + (this, ACE_Event_Handler::EXCEPT_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "notify"), -1); + + else if (ACE_Service_Config::reactor ()->notify + (this, ACE_Event_Handler::WRITE_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "notify"), -1); + + return 0; +} + +// Perform a task that will test the ACE_Reactor's multi-threading +// capabilities in separate threads. + +int +Thread_Handler::svc (void) +{ + for (;;) + { + if (Thread_Handler::delay_.sec () > 0) + // Block for delay_.secs () / 2, then notify the Reactor. + ACE_OS::sleep (Thread_Handler::delay_.sec () / 2); + + this->notify (); + } + return 0; +} + +// Test signal handling. + +int +Thread_Handler::handle_signal (int signum, siginfo_t *, ucontext_t *) +{ + ACE_DEBUG ((LM_DEBUG, "(%t) received signal %S\n", signum)); + + switch (signum) + { + case SIGINT: + case SIGQUIT: + ACE_ERROR ((LM_ERROR, + "(%t) ******************** shutting down %n on signal %S\n", + signum)); + ACE_Service_Config::end_reactor_event_loop (); + } + return 0; +} + +int +Thread_Handler::handle_timeout (const ACE_Time_Value &time, + const void *) +{ + ACE_DEBUG ((LM_DEBUG, "(%t) received timeout at (%u, %u)\n", + time.sec (), time.usec ())); + return 0; +} + +// Called by the ACE_Reactor when it receives a notification. + +int +Thread_Handler::handle_exception (ACE_HANDLE) +{ + ACE_DEBUG ((LM_DEBUG, + "(%t) handle_exception received notification from id %d\n", + this->id_)); + return 0; +} + +// Called by the ACE_Reactor when it receives a notification. + +int +Thread_Handler::handle_output (ACE_HANDLE) +{ + ACE_DEBUG ((LM_DEBUG, + "(%t) handle_output received notification from id %d\n", + this->id_)); + return 0; +} + +// "Shim" function that integrates C thread API with C++. + +void * +Thread_Handler::svc_run (void *eh) +{ + Thread_Handler *this_handler = (Thread_Handler *) eh; + + return this_handler->svc () == 0 ? 0 : (void *) -1; +} + +int +main (int argc, char *argv[]) +{ + // Required to initialize the Service Configurator. + ACE_Service_Config daemon (argv[0]); + + if (argc != 4) + ACE_ERROR ((LM_ERROR, + "usage: %s delay interval n_threads%a\n", + argv[0], 1)); + + int delay = ACE_OS::atoi (argv[1]); + int interval = ACE_OS::atoi (argv[2]); + size_t n_threads = ACE_OS::atoi (argv[3]); + + Thread_Handler thr_handler (delay, interval, n_threads); + + ACE_Service_Config::run_reactor_event_loop (); + ACE_DEBUG ((LM_DEBUG, "exiting from main%a\n", 1)); + return 0; +} +#else +int +main (int, char *[]) +{ + ACE_ERROR_RETURN ((LM_ERROR, + "threads not supported on this platform\n"), -1); +} +#endif /* ACE_HAS_THREADS */ diff --git a/examples/Reactor/Misc/pingpong.cpp b/examples/Reactor/Misc/pingpong.cpp new file mode 100644 index 00000000000..a44267f4e82 --- /dev/null +++ b/examples/Reactor/Misc/pingpong.cpp @@ -0,0 +1,241 @@ +/* Simple program that illustrates all the features of the ACE_Reactor: +// @(#)pingpong.cpp 1.1 10/18/96 + + + 1. I/O event demultiplexing + 2. Signal-based demultiplexing + 3. Timer-based demultiplexing + + To test this program, compile it and then execute it as follows: + + % ./pingpong hello + + You should see lots of the following output: + + writing <4> [7860] + writing <4> [7860] + writing <4> [7860] + writing <4> [7860] + reading <5> (7860) [1] = hello + writing <4> [7860] + writing <5> [7861] + reading <4> (7861) [2] = hello + reading <5> (7860) [2] = hello + writing <4> [7860] + writing <5> [7861] + reading <4> (7861) [3] = hello + reading <5> (7860) [3] = hello + + After 10 seconds you'll see the following: + + ./pingpong: shutting down tester (pid = 7861) + ./pingpong: shutting down tester (pid = 7860) + + and the program will stop. If you'd like to + stop it earlier, just hit the control-C sequence + and you'll see the same messages. */ + +#include "ace/Log_Msg.h" +#include "ace/Synch.h" +#include "ace/Reactor.h" +#include "ace/Pipe.h" + +class Ping_Pong : public ACE_Test_and_Set<ACE_Null_Mutex, sig_atomic_t> +{ +public: + Ping_Pong (char b[], ACE_HANDLE f); + virtual ACE_HANDLE get_handle (void) const; + virtual int handle_input (ACE_HANDLE); + virtual int handle_output (ACE_HANDLE); + virtual int handle_timeout (const ACE_Time_Value &, const void *); + +private: + char buf_[BUFSIZ]; + // Buffer to send. + + size_t buflen_; + // Length of the buffer to send. + + int pid_; + // Process ID. + + ACE_HANDLE handle_; + // Open handle. +}; + +Ping_Pong::Ping_Pong (char b[], ACE_HANDLE f) + : handle_ (f), + buflen_ (ACE_OS::strlen (b) + 1 + (2 * sizeof (int))), + pid_ (ACE_OS::getpid ()) +{ + *((int *) this->buf_) = (int) this->pid_; + *((int *) (this->buf_ + sizeof (int))) = 0; + ACE_OS::strcpy (this->buf_ + (2 * sizeof (int)), b); + this->buf_[this->buflen_ - 1] = '\n'; + this->buf_[this->buflen_] = '\0'; +} + +ACE_HANDLE +Ping_Pong::get_handle (void) const +{ + return this->handle_; +} + +int +Ping_Pong::handle_input (ACE_HANDLE) +{ +#if defined (ACE_HAS_STREAM_PIPES) + // We can rely on record-oriented reads... + + ssize_t n = ACE::recv (this->handle_, this->buf_, this->buflen_); + + if (n != this->buflen_) + ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) reading [%d] %p\n", handle_, "read"), -1); + + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) reading <%d> (%d) [%d] = %s\n", + this->handle_, + *(int *) this->buf_, + *(int *) (this->buf_ + sizeof (int)), + this->buf_ + (2 * sizeof (int)))); +#else + ssize_t n = ACE::recv (this->handle_, this->buf_, sizeof this->buf_); + + if (n == -1) + ACE_ERROR_RETURN ((LM_ERROR, "[%d] %p\n", handle_, "read"), -1); + + n -= (2 * sizeof (int)); + char *buf = this->buf_ + (2 * sizeof (int)); + + ACE_DEBUG ((LM_DEBUG, "(%P|%t) reading <%d> = %*s\n", + this->handle_, n, buf)); +#endif /* ACE_HAS_STREAM_PIPES */ + return 0; +} + +int +Ping_Pong::handle_output (ACE_HANDLE) +{ +#if defined (ACE_HAS_STREAM_PIPES) + // We can rely on record-oriented reads... + + (*(int *) (this->buf_)) = this->pid_; + (*(int *) (this->buf_ + sizeof (int)))++; + if (ACE::send (this->handle_, this->buf_, this->buflen_) == -1) + return -1; + else + { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) writing <%d> [%d]\n", + this->handle_, this->pid_)); + return 0; + } +#else + if (ACE::send (this->handle_, this->buf_, this->buflen_) == -1) + return -1; + else + { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) writing <%d>\n", this->handle_)); + return 0; + } +#endif /* ACE_HAS_STREAM_PIPES */ +} + +int +Ping_Pong::handle_timeout (const ACE_Time_Value &, + const void *) +{ + this->set (1); + return 0; +} + +// Contains the string to "pingpong" back and forth... +static char *string_name; + +// Wait for 10 seconds and then shut down. +static const int SHUTDOWN_TIME = 10; + +#if defined (ACE_WIN32) +static ACE_Barrier barrier (3); + +static void * +worker (void *arg) +{ + ACE_HANDLE handle = (ACE_HANDLE) arg; + + run_svc (handle); + barrier.wait (); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) %n: shutting down tester\n")); + return 0; +} +#endif /* ACE_WIN32 */ + +static void +run_svc (ACE_HANDLE handle) +{ + ACE_Reactor reactor; + + Ping_Pong callback (string_name, handle); + + // Register the callback object for the various I/O, signal, and + // timer-based events. + + if (reactor.register_handler (&callback, + ACE_Event_Handler::READ_MASK + | ACE_Event_Handler::WRITE_MASK) == -1 + || reactor.register_handler (SIGINT, &callback) == -1 + || reactor.schedule_timer (&callback, 0, SHUTDOWN_TIME) == -1) + ACE_ERROR ((LM_ERROR, "%p\n%a", "reactor", 1)); + + // Main event loop (one per process). + + while (callback.is_set () == 0) + reactor.handle_events (); +} + +int +main (int argc, char *argv[]) +{ + ACE_LOG_MSG->open (argv[0]); + + if (argc != 2) + ACE_ERROR ((LM_ERROR, "usage: %n string\n%a", 1)); + + string_name = argv[1]; + + ACE_HANDLE handles[2]; + + // Create a pipe and initialize the handles. + ACE_Pipe pipe (handles); + +#if defined (ACE_WIN32) + if (ACE_Thread::spawn (ACE_THR_FUNC (worker), + (void *) handles[0], + THR_DETACHED) == -1 + || ACE_Thread::spawn (ACE_THR_FUNC (worker), + (void *) handles[1], + THR_DETACHED) == -1) + ACE_ERROR ((LM_ERROR, "%p\n%a", "spawn", 1)); + + barrier.wait (); + +#else + pid_t pid = ACE_OS::fork (); + + if (pid == -1) + ACE_ERROR ((LM_ERROR, "%p\n%a", "fork", 1)); + + // Resync the ACE_Log_Msg notion of process id and program name. + ACE_LOG_MSG->sync (argv[0]); + + run_svc (handles[pid == 0]); + + ACE_DEBUG ((LM_DEBUG, "(%P|%t) %n: shutting down tester\n")); +#endif /* ACE_WIN32 */ + + if (pipe.close () == -1) + ACE_ERROR ((LM_ERROR, "%p\n", "close")); + + return 0; +} diff --git a/examples/Reactor/Misc/signal_tester.cpp b/examples/Reactor/Misc/signal_tester.cpp new file mode 100644 index 00000000000..1631c00b2d0 --- /dev/null +++ b/examples/Reactor/Misc/signal_tester.cpp @@ -0,0 +1,221 @@ +// Perform an extensive test of the ACE_Reactor's event dispatching +// @(#)signal_tester.cpp 1.1 10/18/96 + +// mechanisms. These mechanisms illustrate how signals, I/O, and +// timeout events can all be handled within the same framework. In +// addition, this example illustrates how to use the ACE_Reactor for +// devices that perform I/O via signals (such as SVR4 message queues). + +#include "ace/Log_Msg.h" +#include "ace/Service_Config.h" + +// Used to shut down the event loop. +static sig_atomic_t done = 0; + +// This class illustrates how to handle signal-driven I/O using the +// ACE_Reactor framework. Note that signals may be caught and +// processed without requiring the use of global signal handler +// functions or global signal handler data. + +class Sig_Handler : public ACE_Event_Handler +{ +public: + Sig_Handler (void); + virtual ACE_HANDLE get_handle (void) const; + virtual int handle_input (ACE_HANDLE); + virtual int shutdown (ACE_HANDLE, ACE_Reactor_Mask); + virtual int handle_signal (ACE_HANDLE signum, siginfo_t * = 0, + ucontext_t * = 0); + +private: + ACE_HANDLE handle_; +}; + +// A dummy_handle is required to reserve a slot in the ACE_Reactor's +// descriptor table. + +Sig_Handler::Sig_Handler (void) +{ + // Assign the Sig_Handler a dummy I/O descriptor. Note that even + // though we open this file "Write Only" we still need to use the + // ACE_Event_Handler::NULL_MASK when registering this with the + // ACE_Reactor (see below). + this->handle_ = ACE_OS::open (ACE_DEV_NULL, O_WRONLY); + ACE_ASSERT (this->handle_ != -1); + + // Register signal handler object. Note that NULL_MASK is used to + // keep the ACE_Reactor from calling us back on the "/dev/null" + // descriptor. + if (ACE_Service_Config::reactor ()->register_handler + (this, ACE_Event_Handler::NULL_MASK) == -1) + ACE_ERROR ((LM_ERROR, "%p\n%a", "register_handler", 1)); + + // Create a sigset_t corresponding to the signals we want to catch. + ACE_Sig_Set sig_set; + + sig_set.sig_add (SIGINT); + sig_set.sig_add (SIGQUIT); + sig_set.sig_add (SIGALRM); + + // Register the signal handler object to catch the signals. + if (ACE_Service_Config::reactor ()->register_handler (sig_set, this) == -1) + ACE_ERROR ((LM_ERROR, "%p\n%a", "register_handler", 1)); +} + +// Called by the ACE_Reactor to extract the fd. + +ACE_HANDLE +Sig_Handler::get_handle (void) const +{ + return this->handle_; +} + +// In a real application, this method would be where the read on the +// signal-driven I/O device would occur asynchronously. For now we'll +// just print a greeting to let you know that everything is working +// properly! + +int +Sig_Handler::handle_input (ACE_HANDLE) +{ + ACE_DEBUG ((LM_DEBUG, "handling asynchonrous input...\n")); + return 0; +} + +// In a real application, this method would do any cleanup activities +// required when shutting down the I/O device. + +int +Sig_Handler::shutdown (ACE_HANDLE, ACE_Reactor_Mask) +{ + ACE_DEBUG ((LM_DEBUG, "closing down Sig_Handler...\n")); + return 0; +} + +// This method handles all the signals that are being caught by this +// object. In our simple example, we are simply catching SIGALRM, +// SIGINT, and SIGQUIT. Anything else is logged and ignored. +// +// There are several advantages to using this approach. First, +// the behavior triggered by the signal is handled in the main event +// loop, rather than in the signal handler. Second, the ACE_Reactor's +// signal handling mechanism eliminates the need to use global signal +// handler functions and data. + +int +Sig_Handler::handle_signal (int signum, siginfo_t *, ucontext_t *) +{ + ACE_DEBUG ((LM_DEBUG, "received signal %S\n", signum)); + + switch (signum) + { + case SIGALRM: + // Rearm the alarm. + ACE_OS::alarm (4); + break; + case SIGINT: + // Tell the ACE_Reactor to enable the ready bit for + // this->handle_. The ACE_Reactor will subsequently call the + // Sig_Handler::handle_input method from within its event loop. + return ACE_Service_Config::reactor ()->ready_ops + (this->handle_, ACE_Event_Handler::READ_MASK, ACE_Reactor::ADD_MASK); + case SIGQUIT: + ACE_DEBUG ((LM_DEBUG, "%S: shutting down signal tester\n", signum)); + ACE_Service_Config::end_reactor_event_loop (); + break; + default: + ACE_DEBUG ((LM_DEBUG, + "%S: not handled, returning to program\n", signum)); + break; + } + return 0; +} + +// This class illustrates that the ACE_Reactor can handle signals, +// STDIO, and timeouts using the same mechanisms. + +class STDIN_Handler : public ACE_Event_Handler +{ +public: + STDIN_Handler (void); + virtual int handle_input (ACE_HANDLE); + virtual int handle_timeout (const ACE_Time_Value &, + const void *arg); +}; + +STDIN_Handler::STDIN_Handler (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")); + + // Register the STDIN_Handler to be dispatched once every second. + else if (ACE_Service_Config::reactor ()->schedule_timer + (this, 0, ACE_Time_Value (1), ACE_Time_Value (1)) == -1) + ACE_ERROR ((LM_ERROR, "%p\n%a", "schedule_timer", 1)); +} + +int +STDIN_Handler::handle_timeout (const ACE_Time_Value &tv, + const void *arg) +{ + ACE_DEBUG ((LM_DEBUG, "timeout occurred at %d sec, %d usec\n", + tv.sec (), tv.usec ())); + return 0; +} + +// Read from input descriptor and write to stdout descriptor. + +int +STDIN_Handler::handle_input (ACE_HANDLE handle) +{ + ssize_t n; + char buf[BUFSIZ]; + + switch (n = ACE_OS::read (handle, buf, sizeof buf)) + { + case -1: + if (errno == EINTR) + return 0; + /* NOTREACHED */ + else + ACE_ERROR ((LM_ERROR, "%p\n", "read")); + /* FALLTHROUGH */ + case 0: + ACE_Service_Config::end_reactor_event_loop (); + break; + default: + { + ssize_t result = ACE::write_n (ACE_STDOUT, buf, n); + + if (result != n) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "write"), + result == -1 && errno == EINTR ? 0 : -1); + } + } + return 0; +} + +int +main (int argc, char *argv[]) +{ + ACE_Service_Config daemon (argv [0]); + + // Signal handler. + Sig_Handler sh; + + // Define an I/O handler object. + STDIN_Handler ioh; + + // Optionally start the alarm. + if (argc > 1) + ACE_OS::alarm (4); + + // Loop handling signals and I/O events until SIGQUIT occurs. + + while (daemon.reactor_event_loop_done () == 0) + daemon.run_reactor_event_loop (); + + return 0; +} diff --git a/examples/Reactor/Misc/test_event_handler_t.cpp b/examples/Reactor/Misc/test_event_handler_t.cpp new file mode 100644 index 00000000000..a28108baf10 --- /dev/null +++ b/examples/Reactor/Misc/test_event_handler_t.cpp @@ -0,0 +1,45 @@ +#include "ace/Log_Msg.h" +// @(#)test_event_handler_t.cpp 1.1 10/18/96 + +#include "ace/Event_Handler_T.h" + +#if defined (ACE_HAS_TEMPLATE_TYPEDEFS) + +class ACE_Sig_Handler +{ +public: + ACE_Sig_Handler (void) {} + virtual ACE_HANDLE get_handle (void) const { return 0; } + virtual void set_handle (ACE_HANDLE) {} + virtual int handle_async_io (ACE_HANDLE) { return 0; } + virtual int shutdown (ACE_HANDLE, ACE_Reactor_Mask) { return 0; } + virtual int signal_handler (ACE_HANDLE signum +#if defined (ACE_HAS_SIGINFO_T) + , siginfo_t * = 0, ucontext_t * = 0 +#endif /* ACE_HAS_SIGINFO_T */ + ) + { + return 0; + } +}; + +int +main (void) +{ + typedef ACE_Event_Handler_T<ACE_Sig_Handler> EH_SH; + + // Tie the ACE_Event_Handler_T together with the methods from ACE_Sig_Handler. + EH_SH tied_sh (new ACE_Sig_Handler, 1, + &ACE_Sig_Handler::get_handle, + &ACE_Sig_Handler::handle_async_io, + &ACE_Sig_Handler::shutdown, + &ACE_Sig_Handler::signal_handler); + return 0; +} +#else +int +main (void) +{ + ACE_ERROR_RETURN ((LM_ERROR, "your platform does not support template typedefs\n"), 1); +} +#endif /* ACE_HAS_TEMPLATE_TYPEDEFS */ diff --git a/examples/Reactor/Misc/test_handle_set.cpp b/examples/Reactor/Misc/test_handle_set.cpp new file mode 100644 index 00000000000..65e7db3fc67 --- /dev/null +++ b/examples/Reactor/Misc/test_handle_set.cpp @@ -0,0 +1,75 @@ +#include "ace/Log_Msg.h" +// @(#)test_handle_set.cpp 1.1 10/18/96 + +#include "ace/Handle_Set.h" + +#define IS_ODD(X) (((X) & 1) != 0) + +void +test1 (int count) +{ + int duplicates = 0; + int sets = 0; + int clears = 0; + + ACE_Handle_Set handle_set; + + ACE_OS::srand (ACE_OS::time (0L)); + + for (int i = 0; i < count; i++) + { + int i = int (ACE_OS::rand () % ACE_Handle_Set::MAXSIZE); + + if (IS_ODD (i)) + { + if (handle_set.is_set (i)) + duplicates++; + + handle_set.set_bit (i); + sets++; + } + else + { + if (handle_set.is_set (i)) + duplicates--; + + handle_set.clr_bit (i); + clears++; + } + } + + ACE_DEBUG ((LM_DEBUG, "count = %d, set_size = %d, duplicates = %d\n", + count, handle_set.num_set (), (sets - clears) == duplicates)); +} + +void +test2 (void) +{ + ACE_Handle_Set handle_set; + ACE_HANDLE handle; + + handle_set.set_bit (0); + handle_set.set_bit (1); + handle_set.set_bit (32); + handle_set.set_bit (63); + handle_set.set_bit (64); + handle_set.set_bit (65); + handle_set.set_bit (122); + handle_set.set_bit (129); + handle_set.set_bit (245); + handle_set.set_bit (255); + + for (ACE_Handle_Set_Iterator fi (handle_set); + (handle = fi ()) != -1; + ++fi) + ACE_DEBUG ((LM_DEBUG, "handle = %d\n", handle)); +} + +int +main (int argc, char *argv[]) +{ + int count = argc > 1 ? ACE_OS::atoi (argv[1]) : ACE_Handle_Set::MAXSIZE; + test1 (count); + test2 (); +} + diff --git a/examples/Reactor/Misc/test_reactors.cpp b/examples/Reactor/Misc/test_reactors.cpp new file mode 100644 index 00000000000..81bc1c3a20d --- /dev/null +++ b/examples/Reactor/Misc/test_reactors.cpp @@ -0,0 +1,205 @@ +// Perform a torture test of multiple ACE_Reactors and ACE_Tasks in +// @(#)test_reactors.cpp 1.1 10/18/96 + +// the same process... Thanks to Detlef Becker for contributing this. + +#include "ace/Reactor.h" +#include "ace/Synch.h" +#include "ace/Service_Config.h" +#include "ace/Task.h" + +#if defined (ACE_HAS_THREADS) + +static const int NUM_INVOCATIONS = 10; +static const int MAX_TASKS = 20; + +class Test_Task : public ACE_Task<ACE_MT_SYNCH> +{ +public: + Test_Task (void); + ~Test_Task (void); + + virtual int open (void *args = 0); + virtual int close (u_long flags = 0); + virtual int put (ACE_Message_Block *, ACE_Time_Value *tv = 0); + virtual int svc (void); + + virtual int handle_input (ACE_HANDLE handle); + virtual int handle_close (ACE_HANDLE fd, + ACE_Reactor_Mask close_mask); + +private: + ACE_Reactor *r_; + int handled_; + + static int task_count_; +}; + +int Test_Task::task_count_ = 0; + +static ACE_Atomic_Op<ACE_Thread_Mutex, u_long> done_count = MAX_TASKS * 2; + +static ACE_Recursive_Thread_Mutex reclock_; + +Test_Task::Test_Task (void) + : handled_ (0) +{ + ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon, reclock_); + + Test_Task::task_count_++; + ACE_DEBUG ((LM_DEBUG, + "(%t) TT+ Test_Task::task_count_ = %d\n", + Test_Task::task_count_)); +} + +Test_Task::~Test_Task (void) +{ + ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon, reclock_); + + ACE_DEBUG ((LM_DEBUG, + "(%t) TT- Test_Task::task_count_ = %d\n", + Test_Task::task_count_)); +} + +int +Test_Task::open (void *args) +{ + r_ = (ACE_Reactor *) args; + return this->activate (THR_NEW_LWP); +} + +int +Test_Task::close (u_long flags) +{ + ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, reclock_, -1); + + Test_Task::task_count_--; + ACE_DEBUG ((LM_DEBUG, + "(%t) close Test_Task::task_count_ = %d\n", + Test_Task::task_count_)); + return 0; +} + +int +Test_Task::put (ACE_Message_Block *mb, + ACE_Time_Value *tv) +{ + return 0; +} + +int +Test_Task::svc (void) +{ + for (int i = 0; i < NUM_INVOCATIONS; i++) + { + ACE_OS::thr_yield (); + + // ACE_DEBUG ((LM_DEBUG, "(%t) calling notify %d\n", i)); + + if (r_->notify (this, ACE_Event_Handler::READ_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "notify"), -1); + + // ACE_DEBUG ((LM_DEBUG, "(%t) leaving notify %d\n", i)); + } + + return 0; +} + +int +Test_Task::handle_close (ACE_HANDLE fd, + ACE_Reactor_Mask close_mask) +{ + ACE_DEBUG ((LM_DEBUG, "(%t) handle_close\n")); + return 0; +} + +int +Test_Task::handle_input (ACE_HANDLE fd) +{ + ACE_DEBUG ((LM_DEBUG, "(%t) handle_input\n")); + + this->handled_++; + + if (this->handled_ == NUM_INVOCATIONS) + { + done_count--; + ACE_DEBUG ((LM_DEBUG, + "(%t) handle_input, handled_ = %d, done_count = %d\n", + this->handled_, (u_long) done_count)); + } + + ACE_OS::thr_yield (); + return -1; +} + +static void * +worker (void *args) +{ + ACE_Thread_Control tc (ACE_Service_Config::thr_mgr ()); + ACE_Reactor *reactor = (ACE_Reactor *) args; + + reactor->owner (ACE_Thread::self ()); + + ACE_Time_Value timeout (4); + + for (;;) + { + //ACE_DEBUG ((LM_DEBUG, "(%t) calling handle_events\n")); + + switch (reactor->handle_events (timeout)) + { + case -1: + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "reactor"), 0); + /* NOTREACHED */ + case 0: + ACE_ERROR_RETURN ((LM_ERROR, "timeout\n"), 0); + /* NOTREACHED */ + } + + // ACE_DEBUG ((LM_DEBUG, "(%t) done with handle_events\n")); + + } + + return 0; +} + +int +main (void) +{ + ACE_Reactor *react1 = ACE_Service_Config::reactor (); + ACE_Reactor *react2 = new ACE_Reactor (); + Test_Task tt1[MAX_TASKS]; + Test_Task tt2[MAX_TASKS]; + + for (int i = 0; i < MAX_TASKS; i++) + { + tt1[i].open (react1); + tt2[i].open (react2); + } + + if (ACE_Service_Config::thr_mgr ()->spawn + (ACE_THR_FUNC (worker), (void *) react1, THR_NEW_LWP) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), -1); + + else if (ACE_Service_Config::thr_mgr ()->spawn + (ACE_THR_FUNC (worker), (void *) react2, THR_NEW_LWP) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), -1); + + ACE_Service_Config::thr_mgr ()->wait (); + ACE_DEBUG ((LM_DEBUG, "(%t) done\n")); + + return 42; +} + +#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +template class ACE_Atomic_Op<ACE_Thread_Mutex, u_long>; +#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ + +#else +int +main (int, char *[]) +{ + ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); + return 0; +} +#endif /* ACE_HAS_THREADS */ diff --git a/examples/Reactor/Misc/test_signals.cpp b/examples/Reactor/Misc/test_signals.cpp new file mode 100644 index 00000000000..b3725f66c89 --- /dev/null +++ b/examples/Reactor/Misc/test_signals.cpp @@ -0,0 +1,226 @@ +// Test the ability of the Reactor/Signal_Handler to register multiple +// @(#)test_signals.cpp 1.1 10/18/96 + +// handler per-signal. + +/* This test works as follows: + + 1. To test the "original" semantics of ACE (i.e., only one + ACE_Event_Handler can be registered per signal), you don't + need to do anything special. Existing programs work the + same since giving the Reactor's constructor a 0 value + (which is the default argument, BTW) instructs it to behave + as before. When a 0 is given, the ACE_Reactor's + constructor/open method creates an instance of + ACE_Sig_Handler and assigns this to an internal pointer. + This pointer is then used to dispatch all signal-related + methods within the Reactor. The default ACE_Sig_Handler + only allows *one* ACE_Event_Handler to be registered + per-signal. + + To run this version of the test do the following: + + % ./test-signal + ./test_signals + waiting for SIGINT or SIGQUIT + ^C + signal Interrupt occurred in Sig_Handler_2 (fruity, 0, 0) with count = 1 + waiting for SIGINT or SIGQUIT + ^\ + signal Quit occurred in Sig_Handler_2 (fruity, 0, 0) with count = 2 + shutting down SIGQUIT in Sig_Handler_2 (fruity, 0, 0) + waiting for SIGINT or SIGQUIT + ^C + signal Interrupt occurred in Sig_Handler_2 (fruity, 0, 0) with count = 3 + waiting for SIGINT or SIGQUIT + ^\Quit (core dumped) + + Note that in this test only one handler (the last one -- + "Sig_Handler_2 (fruity)") is actually registered. BTW, the + core dump is the expected behavior since the default + disposition is restored when there are no more handlers + (see the code below). + + 2. To test the "multiple handlers per-signal semantics", you + need to pass the constructor/open method of the ACE_Reactor + a pointer to a an instance of ACE_Sig_Handlers (note the + plural "s"). ACE_Sig_Handlers is a class that derives from + ACE_Sig_Handler. The difference between these two classes + is that (1) ACE_Sig_Handlers::register_signal allows + multiple ACE_Event_Handlers to be registered per-signal and + (2) it enables SA_RESTART by default. This class also + implements Detlef Becker's algorithm for integrating ACE + signal handling with 3rd party libraries. + + To run this version of the test do the following: + + % ./test_signals 1 + + waiting for SIGINT or SIGQUIT + ^C + signal Interrupt occurred in external handler! + signal Interrupt occurred in Sig_Handler_1 (howdy, 3, 1) with count = 1 + shutting down SIGINT in Sig_Handler_1 (howdy, 3, 1) + signal Interrupt occurred in Sig_Handler_1 (doody, 5, 4) with count = 1 + shutting down SIGINT in Sig_Handler_1 (doody, 5, 4) + signal Interrupt occurred in Sig_Handler_2 (tutty, 7, 6) with count = 1 + signal Interrupt occurred in Sig_Handler_2 (fruity, 9, 8) with count = 1 + waiting for SIGINT or SIGQUIT + ^\ + signal Quit occurred in Sig_Handler_1 (howdy, 3, 1) with count = 2 + shutting down SIGQUIT in Sig_Handler_1 (howdy, 3, 1) + signal Quit occurred in Sig_Handler_1 (doody, 5, 4) with count = 2 + shutting down SIGQUIT in Sig_Handler_1 (doody, 5, 4) + signal Quit occurred in Sig_Handler_2 (tutty, 7, 6) with count = 2 + shutting down SIGQUIT in Sig_Handler_2 (tutty, 7, 6) + signal Quit occurred in Sig_Handler_2 (fruity, 9, 8) with count = 2 + shutting down SIGQUIT in Sig_Handler_2 (fruity, 9, 8) + waiting for SIGINT or SIGQUIT + ^C + signal Interrupt occurred in external handler! + signal Interrupt occurred in Sig_Handler_2 (tutty, 7, 6) with count = 3 + signal Interrupt occurred in Sig_Handler_2 (fruity, 9, 8) with count = 3 + waiting for SIGINT or SIGQUIT + ^\Quit (core dumped) + + When this test begins all four handlers are registered and + dispatched when a SIGINT or SIGQUIT occurs. After the + first SIGINT, the handle_signal method of the Sig_Handler_1 + objects unregister themselves. At that point there are 4 + SIGQUIT handlers left, but only 2 of our SIGINT handlers + left (and the 1 external handler). After the first + SIGQUIT, there are no SIGQUIT handlers left since they all + deregister themselves (which restores the "SIG_DFL" + disposition). On the second SIGINT there are only 3 + handlers left (2 of ours and 1 external). Finally, on the + second SIGQUIT we exit and dump core since that's what + happens with the default disposition for SIGQUIT. */ + +#include "ace/Log_Msg.h" +#include "ace/Reactor.h" + +class Sig_Handler_1 : public ACE_Event_Handler +{ +public: + Sig_Handler_1 (ACE_Reactor &reactor, char *msg) + : msg_ (msg), + count_ (0), + reactor_ (reactor) + { + // Register the signal handlers. + this->quit_sigkey_ = reactor.register_handler (SIGQUIT, this); + this->int_sigkey_ = reactor.register_handler (SIGINT, this); + + if (this->quit_sigkey_ == -1 || this->int_sigkey_ == -1) + ACE_ERROR ((LM_ERROR, "%p\n", "register_handler")); + } + + virtual int handle_signal (int signum, siginfo_t *, ucontext_t *) + { + this->count_++; + ACE_DEBUG ((LM_DEBUG, + "\nsignal %S occurred in Sig_Handler_1 (%s, %d, %d) with count = %d", + signum, this->msg_, this->int_sigkey_, this->quit_sigkey_, this->count_)); + if (this->count_ != 1 && signum == SIGQUIT) + { + if (this->reactor_.remove_handler (SIGQUIT, 0, 0, + this->quit_sigkey_) == -1) + ACE_ERROR ((LM_ERROR, "\n%p", "remove_handler")); + else + ACE_DEBUG ((LM_DEBUG, "\nshutting down SIGQUIT in Sig_Handler_1 (%s, %d, %d)", + this->msg_, this->int_sigkey_, this->quit_sigkey_)); + } + else if (this->count_ != 2 && signum == SIGINT) + { + if (this->reactor_.remove_handler (SIGINT, 0, 0, + this->int_sigkey_) == -1) + ACE_ERROR ((LM_ERROR, "\n%p", "remove_handler")); + else + ACE_DEBUG ((LM_DEBUG, "\nshutting down SIGINT in Sig_Handler_1 (%s, %d, %d)", + this->msg_, this->int_sigkey_, this->quit_sigkey_)); + } + return 0; + } + +protected: + char *msg_; + int count_; + int int_sigkey_; + int quit_sigkey_; + ACE_Reactor &reactor_; +}; + +class Sig_Handler_2 : public Sig_Handler_1 +{ +public: + Sig_Handler_2 (ACE_Reactor &reactor, char *msg) + : Sig_Handler_1 (reactor, msg) + { + } + + virtual int handle_signal (int signum, siginfo_t *, ucontext_t *) + { + this->count_++; + ACE_DEBUG ((LM_DEBUG, + "\nsignal %S occurred in Sig_Handler_2 (%s, %d, %d) with count = %d", + signum, this->msg_, this->int_sigkey_, this->quit_sigkey_, this->count_)); + if (this->count_ != 0 && signum == SIGQUIT) + { + if (this->reactor_.remove_handler (SIGQUIT, 0, 0, + this->quit_sigkey_) == -1) + ACE_ERROR ((LM_ERROR, "\n%p", "remove_handler")); + else + ACE_DEBUG ((LM_DEBUG, "\nshutting down SIGQUIT in Sig_Handler_2 (%s, %d, %d)", + this->msg_, this->int_sigkey_, this->quit_sigkey_)); + } + else + return 0; + } +}; + +static void +external_handler (int signum) +{ + ACE_DEBUG ((LM_DEBUG, "\nsignal %S occurred in external handler!", signum)); +} + +#if !defined (HPUX) +int +main (int argc, char *argv) +{ + // If argc > 1 then allow multiple handlers per-signal, else just + // allow 1 handler per-signal. + ACE_Sig_Handlers multi_handlers; + + ACE_Reactor reactor (argc > 1 ? &multi_handlers: 0); + + if (argc > 1) + { + // Register an "external" signal handler so that the + // ACE_Sig_Handlers code will have something to incorporate! + ACE_SignalHandler eh = ACE_SignalHandler (external_handler); + ACE_Sig_Action sa (eh); + + sa.register_action (SIGINT); + } + + // Create a bevy of handlers. + Sig_Handler_1 h1 (reactor, "howdy"), h2 (reactor, "doody"); + Sig_Handler_2 h3 (reactor, "tutty"), h4 (reactor, "fruity"); + + // Wait for user to type SIGINT and SIGQUIT. + + for (;;) + { + ACE_DEBUG ((LM_DEBUG, "\nwaiting for SIGINT or SIGQUIT\n")); + reactor.handle_events (); + } + return 0; +} +#else +int +main (void) +{ + ACE_ERROR_RETURN ((LM_ERROR, "The HP C++ compiler is too lame to support this feature\n"), -1); +} +#endif /* HPUX */ diff --git a/examples/Reactor/Misc/test_time_value.cpp b/examples/Reactor/Misc/test_time_value.cpp new file mode 100644 index 00000000000..691528eb292 --- /dev/null +++ b/examples/Reactor/Misc/test_time_value.cpp @@ -0,0 +1,69 @@ +#include "ace/ACE.h" +// @(#)test_time_value.cpp 1.1 10/18/96 + + +inline int my_abs (int d) { return d > 0 ? d : -d; } + +ostream & +operator<< (ostream &stream, const ACE_Time_Value &tv) +{ + if (tv.usec () < 0 || tv.sec () < 0) + stream << "-"; + + stream << dec << my_abs (int (tv.sec ())) << "." +// << setw (6) << setfill ('0') + << dec << my_abs (int (tv.usec ())); + return stream; +} + +int +main (int argc, char *argv[]) +{ + ACE_Time_Value tv1; + ACE_Time_Value tv2 (2); + ACE_Time_Value tv3 (100); + ACE_Time_Value tv4 (1, 1000000); + ACE_Time_Value tv5 (2); + ACE_Time_Value tv6 (1, -1000000); + + ACE_ASSERT (tv1 == ACE_Time_Value (0)); + ACE_ASSERT (tv2 < tv3); + ACE_ASSERT (tv2 <= tv2); + ACE_ASSERT (tv2 >= tv4); + ACE_ASSERT (tv5 >= tv6); + ACE_ASSERT (tv2 == ACE_Time_Value (1, 1000000)); + ACE_ASSERT (tv5 == tv4); + ACE_ASSERT (tv2 == tv4); + ACE_ASSERT (tv1 != tv2); + ACE_ASSERT (tv6 == tv1); + + cout << "0,0 :\t\t" << ACE_Time_Value (0,0) << endl; + cout << "-0,0 :\t\t" << ACE_Time_Value (-0,0) << endl; + cout << "0,-0 :\t\t" << ACE_Time_Value (0,-0) << endl; + cout << "-0,-0 :\t\t" << ACE_Time_Value (-0,-0) << endl; + cout << endl; + + cout << "0,1 :\t\t" << ACE_Time_Value (0,1) << endl; + cout << "1,0 :\t\t" << ACE_Time_Value (1,0) << endl; + cout << "-1,0 :\t\t" << ACE_Time_Value (-1,0) << endl; + cout << "-1,-0 :\t\t" << ACE_Time_Value (-1,-0) << endl; + cout << endl; + + cout << "1,1 :\t\t" << ACE_Time_Value (1,1) << endl; + cout << "-1,1 :\t\t" << ACE_Time_Value (-1,1) << endl; + cout << "1,-1 :\t\t" << ACE_Time_Value (1,-1) << endl; + cout << "-1,-1 :\t\t" << ACE_Time_Value (-1,-1) << endl; + cout << endl; + + cout << "1,-1111111 :\t" << ACE_Time_Value (1,-1111111) << endl; + cout << "1,-100000 :\t" << ACE_Time_Value (1,-100000) << endl; + cout << "1,-1000000 :\t" << ACE_Time_Value (1,-1000000) << endl; + cout << "-1,1000000 :\t" << ACE_Time_Value (-1,1000000) << endl; + cout << "5,-1000000 :\t" << ACE_Time_Value (5,-1000000) << endl; + cout << "5,-1500000 :\t" << ACE_Time_Value (5,-1500000) << endl; + cout << "2,-2500000 :\t" << ACE_Time_Value (2,-2500000) << endl; + cout << "2,-4500000 :\t" << ACE_Time_Value (2,-4500000) << endl; + + return 0; +} + diff --git a/examples/Reactor/Misc/test_timer_queue.cpp b/examples/Reactor/Misc/test_timer_queue.cpp new file mode 100644 index 00000000000..4e7010d1e94 --- /dev/null +++ b/examples/Reactor/Misc/test_timer_queue.cpp @@ -0,0 +1,47 @@ +#include "ace/Log_Msg.h" +// @(#)test_timer_queue.cpp 1.1 10/18/96 + +#include "ace/Timer_Queue.h" + +class Example_Handler : public ACE_Event_Handler +{ +public: + Example_Handler (void) + : count_ (0) + {} + + virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg) + { + ACE_DEBUG ((LM_DEBUG, "yow, the time has come and gone %d times %d, Horatio!\n", + this->count_++, int (arg))); + return 0; + } + +private: + int count_; +}; + +int +main (int argc, char *argv[]) +{ + ACE_Timer_Queue tq; + Example_Handler eh; + + ACE_ASSERT (tq.is_empty ()); + ACE_ASSERT (ACE_Time_Value::zero == ACE_Time_Value (0)); + int timer_id; + + timer_id = tq.schedule (&eh, (const void *) 1, ACE_OS::gettimeofday ()); + tq.schedule (&eh, (const void *) 2, ACE_OS::gettimeofday ()); + tq.schedule (&eh, (const void *) 3, ACE_OS::gettimeofday ()); + tq.cancel (timer_id); + ACE_ASSERT (!tq.is_empty ()); + tq.expire (ACE_OS::gettimeofday ()); + tq.schedule (&eh, (const void *) 4, ACE_OS::gettimeofday ()); + tq.schedule (&eh, (const void *) 5, ACE_OS::gettimeofday ()); + tq.cancel (&eh); + ACE_ASSERT (tq.is_empty ()); + tq.expire (ACE_OS::gettimeofday ()); + return 0; +} + diff --git a/examples/Reactor/Multicast/Log_Wrapper.cpp b/examples/Reactor/Multicast/Log_Wrapper.cpp new file mode 100644 index 00000000000..0b0526cdf2c --- /dev/null +++ b/examples/Reactor/Multicast/Log_Wrapper.cpp @@ -0,0 +1,75 @@ +// client.C +// @(#)Log_Wrapper.cpp 1.1 10/18/96 + + +#include "Log_Wrapper.h" + +Log_Wrapper::Log_Wrapper (void) +{ + this->log_msg_.sequence_number = 0; + this->log_msg_.app_id = ACE_OS::getpid(); +} + +Log_Wrapper::~Log_Wrapper (void) +{ +} + +// Set the log_msg_ host address. +// Get a binding to a logger object from orbixd + +int +Log_Wrapper::open (const int port, const char *mcast_addr) +{ + struct hostent *host_info; + struct utsname host_data; + + if (ACE_OS::uname (&host_data) < 0) + return -1; + + if ((host_info = ACE_OS::gethostbyname (host_data.nodename)) == NULL) + return -1; + else + ACE_OS::memcpy ((char *) &this->log_msg_.host, + (char *) host_info->h_addr, + host_info->h_length); + + // This starts out initialized to all zeros! + ACE_INET_Addr sockdg_addr; + + if (this->logger_.open (sockdg_addr) == -1) + return -1; + + if (this->server_.set (port, mcast_addr) == -1) + return -1; + + // success. + return 0; +} + +// Send the message to a logger object. +// This wrapper fills in all the log_record info for you. +// uses iovector stuff to make contiguous header and message. + +int +Log_Wrapper::log_message (ACE_Log_Priority type, char *message) +{ + this->log_msg_.type = type; this->log_msg_.time = time (0); + this->log_msg_.msg_length = strlen(message); + this->log_msg_.sequence_number++; + + iovec *iovp = new iovec[2]; + iovp[0].iov_base = (char *) &log_msg_; + iovp[0].iov_len = sizeof log_msg_; + iovp[1].iov_base = message; + iovp[1].iov_len = log_msg_.msg_length; + + logger_.send (iovp, 2, server_); + + delete iovp; + + // success. + return 0; +} + + + diff --git a/examples/Reactor/Multicast/Log_Wrapper.h b/examples/Reactor/Multicast/Log_Wrapper.h new file mode 100644 index 00000000000..d1932d92cfa --- /dev/null +++ b/examples/Reactor/Multicast/Log_Wrapper.h @@ -0,0 +1,59 @@ +/* -*- C++ -*- */ +// @(#)Log_Wrapper.h 1.1 10/18/96 + + +// log_wrapper.h +// wrapper around sending log messages via multicast + +#include "ace/Profile_Timer.h" +#include "ace/INET_Addr.h" +#include "ace/SOCK_Dgram.h" + +#if !defined (_LM_WRAPPER_H) +#define _LM_WRAPPER_H + +class Log_Wrapper +{ +public: + Log_Wrapper (void); + ~Log_Wrapper (void); + + // = Types of logging messages. + enum ACE_Log_Priority + { + LM_MESSAGE, + LM_DEBUG, + LM_WARNING, + LM_ERROR, + LM_EMERG + }; + + int open (const int port, const char* mcast_addr); + // get an object reference from an orbixd + + int log_message (ACE_Log_Priority type, char *message); + // send a string to the logger + + // = Format of the logging record. + struct ACE_Log_Record + { + unsigned long sequence_number; + ACE_Log_Priority type; + long host; + long time; + long app_id; + long msg_length; + }; + +private: + ACE_INET_Addr server_; + // Server address where records are logged. + + ACE_Log_Record log_msg_; + // One record used for many log messages. + + ACE_SOCK_Dgram logger_; + // A logger object. +}; + +#endif /* _LM_WRAPPER_H */ diff --git a/examples/Reactor/Multicast/Makefile b/examples/Reactor/Multicast/Makefile new file mode 100644 index 00000000000..980cb7d28b3 --- /dev/null +++ b/examples/Reactor/Multicast/Makefile @@ -0,0 +1,69 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the Reactor multicast tests +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = client server + +FILES = Log_Wrapper + +LSRC = $(addsuffix .cpp,$(FILES)) +LOBJ = $(addsuffix .o,$(FILES)) +SHOBJ = $(addsuffix .so,$(FILES)) + +LDLIBS = $(addprefix .shobj/,$(SHOBJ)) + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# ACE stuff +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.lib.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/Log_Wrapper.o .shobj/Log_Wrapper.so: Log_Wrapper.cpp Log_Wrapper.h \ + $(WRAPPER_ROOT)/ace/Profile_Timer.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Dgram.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_Dgram.i + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/Reactor/Multicast/README b/examples/Reactor/Multicast/README new file mode 100644 index 00000000000..85f64cc8120 --- /dev/null +++ b/examples/Reactor/Multicast/README @@ -0,0 +1,15 @@ +The following test illustrates the SOCK Mcast multicast wrappers in +conjunction with the Reactor. This test was written by Tim Harrison +(harrison@cs.wustl.edu). + +To run the server type: + +% server & + +It will wait for the first message sent to it and then read for 5 seconds. + +To run the client type any of these: + +% client -m max_message_size -i iterations +% client < <filename> +% client diff --git a/examples/Reactor/Multicast/client.cpp b/examples/Reactor/Multicast/client.cpp new file mode 100644 index 00000000000..1f5774fdb26 --- /dev/null +++ b/examples/Reactor/Multicast/client.cpp @@ -0,0 +1,110 @@ +// client.C (written by Tim Harrison) +// @(#)client.cpp 1.1 10/18/96 + +// This program reads in messages from stdin and sends them +// to a Log_Wrapper. + +#include "ace/Log_Msg.h" +#include "Log_Wrapper.h" + +const char *MCAST_ADDR = ACE_DEFAULT_MULTICAST_ADDR; + +// this is hardware specific. +// use netstat(1M) to find whether your interface +// is le0 or ie0 + +const int UDP_PORT = ACE_DEFAULT_MULTICAST_PORT; + +// maximum message size +static int max_message_size = BUFSIZ * 20; + +// number of times to send message of max_message_size +static int iterations = 0; + +static void +parse_args (int argc, char *argv[]) +{ + extern char *optarg; + extern int optind; + int c; + + ACE_LOG_MSG->open (argv[0]); + + while ((c = ACE_OS::getopt (argc, argv, "m:ui:")) != -1) + switch (c) + { + case 'm': + max_message_size = ACE_OS::atoi (optarg) * BUFSIZ; + break; + case 'i': + iterations = ACE_OS::atoi (optarg); + break; + case 'u': + // usage fallthrough + default: + ACE_ERROR ((LM_ERROR, "%n: -m max_message_size (in k) -i iterations\n%a", 1)); + /* NOTREACHED */ + } +} + +int +main (int argc, char **argv) +{ + int user_prompt; + + parse_args (argc,argv); + + ACE_DEBUG ((LM_DEBUG, "Max Buffer size = %d\n", max_message_size)); + + // Instantiate a log wrapper for logging + Log_Wrapper log; + + // make a connection to a logger via orbixd + if (log.open (UDP_PORT, MCAST_ADDR) == -1) + ACE_OS::perror ("connect failed"), ACE_OS::exit (1); + + char *buf = new char[::max_message_size]; + + // if -i has been specified, send max_message_size messages + // iterations number of times + if (iterations) + { + ACE_OS::memset (buf,1,::max_message_size); + while (iterations--) + if (log.log_message (Log_Wrapper::LM_DEBUG, buf) == -1) + perror("log failed."), exit(1); + } + + // otherwise, a file has been redirected, or give prompts + else + { + // If a file has been redirected, don't activate user prompts + if (ACE_OS::isatty (0)) + user_prompt = 1; + else + user_prompt = 0; + + int nbytes; + // continually read messages from stdin and log them. + while (1) + { + if (user_prompt) + ACE_DEBUG ((LM_DEBUG, "\nEnter message ('Q':quit):\n")); + + if ((nbytes = read (0, buf, max_message_size)) == 0) + break; // end of file + buf[nbytes] = '\0'; + + // quitting? + if (buf[0] == 'Q') + break; + + // send the message to the logger + else if (log.log_message (Log_Wrapper::LM_DEBUG, buf) == -1) + perror("log failed."), exit(1); + } // while(1) + } + + ACE_DEBUG ((LM_DEBUG, "Client done.\n")); + return 0; +} diff --git a/examples/Reactor/Multicast/server.cpp b/examples/Reactor/Multicast/server.cpp new file mode 100644 index 00000000000..b9c3942a9a7 --- /dev/null +++ b/examples/Reactor/Multicast/server.cpp @@ -0,0 +1,157 @@ +// server.C (written by Tim Harrison) +// @(#)server.cpp 1.1 10/18/96 + +// +// listens to multicast address. after first message received, will +// listen for 5 more seconds. prints Mbits/sec received from client. + +#include "ace/SOCK_Dgram.h" +#include "ace/INET_Addr.h" +#include "ace/Log_Msg.h" +#include "ace/SOCK_Dgram_Mcast.h" +#include "ace/Reactor.h" +#include "Log_Wrapper.h" + +#if defined (ACE_HAS_IP_MULTICAST) +class Server_Events : public ACE_Event_Handler +{ +public: + Server_Events (u_short port, + const char *mcast_addr, + long time_interval = 0); + ~Server_Events (void); + + virtual int handle_input (ACE_HANDLE fd); + virtual ACE_HANDLE get_handle (void) const; + + ACE_Time_Value *wait_time (void); + +private: + char *message_; + Log_Wrapper::ACE_Log_Record *log_record_; + char buf_[4*BUFSIZ]; + + int interval_; + // time interval to log messages + + ACE_Time_Value *how_long_; + ACE_Reactor *reactor_; + ACE_SOCK_Dgram_Mcast mcast_dgram_; + ACE_INET_Addr remote_addr_; + ACE_INET_Addr mcast_addr_; + + // = statistics on messages received + double total_bytes_received_; + int total_messages_received_; + int last_sequence_number_; +}; + +ACE_HANDLE +Server_Events::get_handle (void) const +{ + return this->mcast_dgram_.get_handle (); +} + +ACE_Time_Value * +Server_Events::wait_time (void) +{ + return this->how_long_; +} + +Server_Events::Server_Events (u_short port, + const char *mcast_addr, + long time_interval) + : total_bytes_received_ (0), + interval_ (time_interval), + mcast_addr_ (port, mcast_addr) +{ + // use ACE_SOCK_Dgram_Mcast factory to subscribe to multicast group. + + if (this->mcast_dgram_.subscribe (this->mcast_addr_) == -1) + perror("can't subscribe to multicast group"), exit(1); + + // Point to NULL so that we block in the beginning. + this->how_long_ = 0; + + this->log_record_ = (Log_Wrapper::ACE_Log_Record *) &buf_; + this->message_ = &buf_[sizeof (Log_Wrapper::ACE_Log_Record)]; +} + +// A destructor that emacs refuses to color blue ;-) + +Server_Events::~Server_Events (void) +{ + this->mcast_dgram_.unsubscribe (); + + ACE_DEBUG ((LM_DEBUG, "total bytes received = %d after %d second\n", + this->total_bytes_received_, this->interval_)); + + ACE_DEBUG ((LM_DEBUG, "Mbits/sec = %.2f\n", + (float) (total_bytes_received_ * 8 / (float) (1024*1024*interval_)))); + + ACE_DEBUG ((LM_DEBUG, + "last sequence number = %d\ntotal messages received = %d\ndiff = %d\n", + this->last_sequence_number_, + this->total_messages_received_, + this->last_sequence_number_ - total_messages_received_)); +} + +int +Server_Events::handle_input (ACE_HANDLE fd) +{ + // after the first message, point this to a timer + // that way, the next time reactor::handle_events is called, + // a nonzero time value will be passed in. + if (this->how_long_ == 0) + this->how_long_ = new ACE_Time_Value (this->interval_); + + // receive message from multicast group + int retcode = this->mcast_dgram_.recv (this->buf_, + sizeof this->buf_, + this->remote_addr_); + if (retcode != -1) + { + total_messages_received_++; + total_bytes_received_ += retcode; + last_sequence_number_ = log_record_->sequence_number; + ACE_DEBUG ((LM_DEBUG, "sequence number = %d\n", + log_record_->sequence_number)); + return 0; + } + else + return -1; +} + +static const char MCAST_ADDR[] = ACE_DEFAULT_MULTICAST_ADDR; +static const int UDP_PORT = ACE_DEFAULT_MULTICAST_PORT; + +int +main(int argc, char *argv[]) +{ + int duration = 5; + + // Instantiate a server which will receive messages for 5 seconds. + Server_Events server_events (UDP_PORT, MCAST_ADDR, duration); + + // Instance of the ACE_Reactor. + ACE_Reactor reactor; + + if (reactor.register_handler (&server_events, + ACE_Event_Handler::READ_MASK) == -1) + ACE_ERROR ((LM_ERROR, "%p\n%a", "register_handler", 1)); + + for (;;) + reactor.handle_events (server_events.wait_time ()); + + /* NOTREACHED */ + return 0; +} +#else +int +main (int argc, char *argv[]) +{ + ACE_ERROR_RETURN ((LM_ERROR, + "error: %s must be run on a platform that support IP multicast\n", + argv[0]), -1); +} +#endif /* ACE_HAS_IP_MULTICAST */ diff --git a/examples/Reactor/Ntalker/Makefile b/examples/Reactor/Ntalker/Makefile new file mode 100644 index 00000000000..d01010c27a0 --- /dev/null +++ b/examples/Reactor/Ntalker/Makefile @@ -0,0 +1,91 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for ntalker demo of SOCK_Dgram_Mcast +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = ntalker + +SRC = $(addsuffix .cpp,$(BIN)) + +LDLIBS = +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# ACE stuff +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.lib.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/ntalker.o .shobj/ntalker.so: ntalker.cpp \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Dgram_Mcast.h \ + $(WRAPPER_ROOT)/ace/SOCK_Dgram.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_Dgram.i \ + $(WRAPPER_ROOT)/ace/SOCK_Dgram_Mcast.i \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/Reactor/Ntalker/ntalker.cpp b/examples/Reactor/Ntalker/ntalker.cpp new file mode 100644 index 00000000000..54c8e20f453 --- /dev/null +++ b/examples/Reactor/Ntalker/ntalker.cpp @@ -0,0 +1,188 @@ +// Server.C +// @(#)ntalker.cpp 1.1 10/18/96 + +// +// listens to multicast address. after first message received, will +// listen for 5 more seconds. prints Mbits/sec received from client + +#include "ace/INET_Addr.h" +#include "ace/SOCK_Dgram_Mcast.h" +#include "ace/Reactor.h" + +#if defined (ACE_HAS_IP_MULTICAST) +// network interface to subscribe to +// this is hardware specific. +// use netstat(1M) to find whether your interface +// is le0 or ie0 + +static const char *interface = "le0"; +static const char *MCAST_ADDR = ACE_DEFAULT_MULTICAST_ADDR; +static const u_short UDP_PORT = ACE_DEFAULT_MULTICAST_PORT; + +// Handle both multicast and stdin events. + +class Handle_Events : public ACE_Event_Handler +{ +public: + Handle_Events (u_short udp_port, + const char *ip_addr, + const char *interface, + ACE_Reactor &reactor); + ~Handle_Events (void); + + virtual int handle_input (ACE_HANDLE); + virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask); + +private: + ACE_SOCK_Dgram_Mcast mcast_; + ACE_Handle_Set handle_set_; +}; + +int +Handle_Events::handle_input (ACE_HANDLE h) +{ + char buf[BUFSIZ]; + + if (h == 0) + { + int readresult = ACE_OS::read (h, buf, BUFSIZ); + if (readresult > 0) + { + if (this->mcast_.send (buf, readresult) != readresult) + { + ACE_OS::perror ("send error"); + return -1; + } + return 0; + } + else if (readresult == -1) + ::perror ("can't read from STDIN"); + + return -1; + } + else + { + ACE_INET_Addr remote_addr; + + // receive message from multicast group + int retcode = this->mcast_.recv (buf, sizeof buf, remote_addr); + + if (retcode != -1) + { + cout << "received datagram from host " << remote_addr.get_host_name () + << " on port " << remote_addr.get_port_number () + << " bytes = " << retcode << endl; + ACE_OS::write (ACE_STDOUT, buf, retcode); + cout << endl; + return 0; + } + + ACE_OS::perror ("Something amiss."); + return -1; + } +} + +int +Handle_Events::handle_close (ACE_HANDLE h, ACE_Reactor_Mask) +{ + if (h == 0) + cout << "STDIN_Events handle removed from reactor." << endl << flush; + else + cout << "Mcast_Events handle removed from reactor." << endl << flush; + return 0; +} + +Handle_Events::~Handle_Events (void) +{ + // ACE_OS::exit on error (bogus)... + + if (this->mcast_.unsubscribe () == -1) + ACE_OS::perror ("unsubscribe fails"), ACE_OS::exit (1); +} + +Handle_Events::Handle_Events (u_short udp_port, + const char *ip_addr, + const char *interface, + ACE_Reactor &reactor) +{ + // Create multicast address to listen on. + + ACE_INET_Addr sockmc_addr (udp_port, ip_addr); + + // subscribe to multicast group. + + if (this->mcast_.subscribe (sockmc_addr, 1, interface) == -1) + ACE_OS::perror ("can't subscribe to multicast group"), ACE_OS::exit (1); + + // disable loopbacks + +// if (this->mcast_.set_option (IP_MULTICAST_LOOP, 0) == -1 ) +// ACE_OS::perror (" can't disable loopbacks " ), ACE_OS::exit (1); + + this->handle_set_.set_bit (0); + this->handle_set_.set_bit (this->mcast_.get_handle ()); + + // Register callbacks with the ACE_Reactor. + if (reactor.register_handler (this->handle_set_, + this, + ACE_Event_Handler::READ_MASK) == -1) + ACE_OS::perror ("can't register events"), ACE_OS::exit (1); +} + +static void +parse_args (int argc, char *argv[]) +{ + extern char *optarg; + extern int optind; + int c; + + while ((c = ACE_OS::getopt (argc, argv, "i:u")) != -1) + switch (c) + { + case 'i': + interface = optarg; + break; + case 'u': + // usage fallthrough + default: + cerr << argv[0] << " -i interface\n"; + ::exit (1); + } +} + +static sig_atomic_t done = 0; + +// Signal handler. + +static void +handler (int) +{ + done = 1; +} + +int +main (int argc, char *argv[]) +{ + ACE_Sig_Action sig ((ACE_SignalHandler) handler, SIGINT); + parse_args (argc, argv); + + ACE_Reactor reactor; + Handle_Events handle_events (UDP_PORT, MCAST_ADDR, interface, reactor); + + // main loop + + while (!done) + reactor.handle_events (); + + cout << "\ntalker Done.\n"; + return 0; +} +#else +int +main (int argc, char *argv[]) +{ + ACE_ERROR ((LM_ERROR, "error: %s must be run on a platform that support IP multicast\n", + argv[0])); + return 0; +} +#endif /* ACE_HAS_IP_MULTICAST */ diff --git a/examples/Reactor/README b/examples/Reactor/README new file mode 100644 index 00000000000..fefaeeaf317 --- /dev/null +++ b/examples/Reactor/README @@ -0,0 +1,20 @@ +This directory contains subdirectories that test the ACE Reactor and Proactor + + . Dgram + Tests the CODgram and Dgram classes with the Reactor. + + . Misc + Various miscellaneous tests of Reactor functionality + (e.g., signals, timers, notification, etc.). + + . Multicast + Tests out the ACE multicast capabilities in conjunction + with the Reactor. + + . Ntalker + A program that implements a multicast "chat" program. + + + . Proactor + A program that illustrates the "Proactive" version of + the Reactor diff --git a/examples/Reactor/ReactorEx/README b/examples/Reactor/ReactorEx/README new file mode 100644 index 00000000000..1184d09dd68 --- /dev/null +++ b/examples/Reactor/ReactorEx/README @@ -0,0 +1,204 @@ +The ACE_ReactorEx encapsulates the Win32 WaitForMultipleObjects() API +within ACE. The ACE_ReactorEx is similar in spirit to the +ACE_Reactor, except that (1) it is much simpler and (2) it works for +the complete range of Win32 handles (whereas the ACE_Reactor just +works for socket handles. + +Here's the API for the ACE_ReactorEx: + +class ACE_ReactorEx +{ +public: + // = Event loop. + virtual int handle_events (ACE_Time_Value *); + + // = Handler registration management. + virtual int register_handler (ACE_Event_Handler *); + virtual int remove_handler (ACE_Event_Handler *); + + virtual int notify (void); + + // = Timer management + virtual int schedule_timer (), etc. + // ... +}; + +---------------------------------------- + +Here's how you might use it: + +---------------------------------------- + +class My_Thread_Handler : public ACE_Event_Handler +{ +public: + My_Thread_Handler (void) { + // Create a thread that will run + // for a time and then exit. + this->thread_handle_ = + ACE_OS::thr_create (run, ......); + } + + // Called back by the ACE_ReactorEx when the + // event is signaled. + virtual int handle_signal (int) + { + cout << "thread is done" << endl; + } + + virtual ACE_HANDLE get_handle (void) const + { + return this->thread_handle_; + } + +private: + ACE_HANDLE thread_handle_; + + static void *run (void *) { + // Sleep for a while and then exit. + ACE_OS::sleep (100000); + return 0; + } +}; + +---------------------------------------- + +The main program might look something like this: + +---------------------------------------- + +int main (void) +{ + // ... + ACE_ReactorEx dispatcher; + My_Thread_Handler handler; + + // Register the thread handler. + dispatcher.register_handler (&handler); + + // Block until the thread exits and the + // handle_signal() method of the My_Thread_Handler + // is called! + dispatcher.handle_events (); + + // ... +} + +---------------------------------------- + +. test_remove_handler -- + +This application tests the ReactorEx's ability to handle simultaneous +events. If you pass anything on the command-line, then each handler +requests to be removed from the ReactorEx after each event. This has +a funky effect on the order in which handlers are serviced. So, if no +parameters are passed in, the handlers should be serviced 1 through +MAXIMUM_WAIT_OBJECTS. If handlers to request to be removed as signals +occur, they will be serviced 1, MAX, MAX-1, ..., 2. This is because +of a ReactorEx bookkeeping optimization. + +. test_reactorEx.cpp -- + +This test application tests a wide range of events that can be +demultiplexed using various ACE utilities. Events used include ^C +events, reading from STDIN, vanilla Win32 events, thread exits, +ReactorEx notifications, proactive reads, and proactive writes. + +The proactive I/O events are demultiplexed by the ACE_Proactor. The +thread exits, notications, and vanilla Win32 events are demultiplexed +by the ACE_ReactorEx. To enable a single thread to run all these +events, the Proactor is integrated with the ReactorEx. + +The test application prototypes a simple ntalk program. Two instances +of the application connect. Input from either console is displayed on +the others console also. Because of the evils of Win32 STDIN, a +separate thread is used to read from STDIN. To test the Proactor and +ReactorEx, I/O between the remote processes is performed proactively +and interactions between the STDIN thread and the main thread are +performed reactively. + +The following description of the test application is in two parts. +The participants section explains the main components involved in the +application. The collaboration section describes how the partipants +interact in response to the multiple event types which occur. + +The ReactorEx test application has the following participants: + +. ReactorEx -- The ReactorEx demultiplexes Win32 "waitable" events + using WaitForMultipleObjects. + +. Proactor -- The proactor initiates and demultiplexes overlapped I/O + operations. The Proactor registers with the ReactorEx so that a + single-thread can demultiplex all application events. + +. STDIN_Handler -- STDIN_Handler is an Active Object which reads from + STDIN and forwards the input to the Peer_Handler. This runs + in a separate thread to make the test more interesting. However, + STDIN is "waitable", so in general it can be waited on by the ACE + ReactorEx, thanks MicroSlush! + +. Peer_Handler -- The Peer_Handler connects to another instance of + test_reactorEx. It Proactively reads and writes data to the peer. + When the STDIN_Handler gives it messages, it fowards them to the + remote peer. When it receives messages from the remote peer, it + prints the output to the console. + +The collaborations of the participants are as follows: + +. Initialization + + Peer_Handler -- connects to the remote peer. It then begins + proactively reading from the remote connection. Note that it will + be notified by the Proactor when a read completes. It also + registers a new_msg_event with the ReactorEx. Note that when the + new_msg_event is signaled (by the STDIN_Handler), + Peer_Handler::handle_signal will get called. + + STDIN_Handler -- STDIN_Handler registers a signal handler for + SIGINT. This just captures the exception so that the kernel doesn't + kill our process; We want to exit gracefully. It also creates an + Exit_Hook object which registers the STDIN_Handler's thread handle + with the ReactorEx. The Exit_Hook will get called back when the + STDIN_Handler thread exits. After registering these, it blocks + reading from STDIN. + + Proactor -- is registered with the ReactorEx. + + The main thread of control waits in the ReactorEx. + +. STDIN events -- When the STDIN_Handler thread reads from STDIN, it + puts the message on Peer_Handler's message queue and signals the + new_msg_event. It then returns to reading from STDIN. + +. new_msg_events -- The ReactorEx thread wakes up and calls + Peer_Handler::handle_signal. The Peer_Handler then tries to dequeue + a message from its message queue. If it can, the message is + Proactively sent to the remote peer. Note that the Peer_Handler + will be notified with this operation is complete. The Peer_Handler + then falls back into the ReactorEx event loop. + +. Send complete event -- When a proactive send is complete, the + Proactor is notified by the ReactorEx. The Proactor, in turn, + notifies the Peer_Handler. The Peer_Handler then checks for more + messages from the message queue. If there are any, it tries to send + them. If there are not, it returns to the ReactorEx event loop. + This is ok since it is notified via new_msg_event when new message + arrive. + +. Read complete event -- When a proactive read is complete (the + Peer_Handler initiated a proactive read when it connected to the + remote peer), the Proactor is notified by the ReactorEx. The + Proactor, in turn notifies the Peer_Handler. If the read was + successful the Peer_Handler just displays the received msg to the + console and reinvokes a proactive read from the network connection. + If the read failed (i.e. the remote peer exited), the Peer_Handler + sets a flag to end the event loop and returns. This will cause the + application to exit. + +. ^C events -- When the user types ^C at the console, the + STDIN_Handler's signal handler will be called. It does nothing, but + as a result of the signal, the STDIN_Handler thread will exit. + +. STDIN_Handler thread exits -- The Exit_Hook will get called back + from the ReactorEx. Exit_Hook::handle_signal sets a flag to end the + event loop and returns. This will cause the application to exit. diff --git a/examples/Reactor/ReactorEx/reactorex.mak b/examples/Reactor/ReactorEx/reactorex.mak new file mode 100644 index 00000000000..150d04508d7 --- /dev/null +++ b/examples/Reactor/ReactorEx/reactorex.mak @@ -0,0 +1,535 @@ +# Microsoft Developer Studio Generated NMAKE File, Format Version 4.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+!IF "$(CFG)" == ""
+CFG=test_remove_handler - Win32 Debug
+!MESSAGE No configuration specified. Defaulting to test_remove_handler - Win32\
+ Debug.
+!ENDIF
+
+!IF "$(CFG)" != "ntalk - Win32 Release" && "$(CFG)" != "ntalk - Win32 Debug" &&\
+ "$(CFG)" != "test_remove_handler - Win32 Release" && "$(CFG)" !=\
+ "test_remove_handler - Win32 Debug"
+!MESSAGE Invalid configuration "$(CFG)" specified.
+!MESSAGE You can specify a configuration when running NMAKE on this makefile
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "reactorEx.mak" CFG="test_remove_handler - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "ntalk - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "ntalk - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE "test_remove_handler - Win32 Release" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE "test_remove_handler - Win32 Debug" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE
+!ERROR An invalid configuration is specified.
+!ENDIF
+
+!IF "$(OS)" == "Windows_NT"
+NULL=
+!ELSE
+NULL=nul
+!ENDIF
+################################################################################
+# Begin Project
+# PROP Target_Last_Scanned "ntalk - Win32 Debug"
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "ntalk - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "ntalk\Release"
+# PROP BASE Intermediate_Dir "ntalk\Release"
+# PROP BASE Target_Dir "ntalk"
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "ntalk\Release"
+# PROP Intermediate_Dir "ntalk\Release"
+# PROP Target_Dir "ntalk"
+OUTDIR=.\ntalk\Release
+INTDIR=.\ntalk\Release
+
+ALL : "$(OUTDIR)\ntalk.exe"
+
+CLEAN :
+ -@erase ".\ntalk\Release\ntalk.exe"
+ -@erase ".\ntalk\Release\test_reactorEx.obj"
+
+"$(OUTDIR)" :
+ if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
+# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
+CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\
+ /Fp"$(INTDIR)/ntalk.pch" /YX /Fo"$(INTDIR)/" /c
+CPP_OBJS=.\ntalk\Release/
+CPP_SBRS=
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+BSC32_FLAGS=/nologo /o"$(OUTDIR)/ntalk.bsc"
+BSC32_SBRS=
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ace.lib /nologo /subsystem:console /machine:I386
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
+ advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
+ odbccp32.lib ace.lib /nologo /subsystem:console /incremental:no\
+ /pdb:"$(OUTDIR)/ntalk.pdb" /machine:I386 /out:"$(OUTDIR)/ntalk.exe"
+LINK32_OBJS= \
+ "$(INTDIR)/test_reactorEx.obj"
+
+"$(OUTDIR)\ntalk.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ELSEIF "$(CFG)" == "ntalk - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "ntalk\Debug"
+# PROP BASE Intermediate_Dir "ntalk\Debug"
+# PROP BASE Target_Dir "ntalk"
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "debug"
+# PROP Target_Dir "ntalk"
+OUTDIR=.
+INTDIR=.\debug
+
+ALL : "$(OUTDIR)\test_reactorEx.exe"
+
+CLEAN :
+ -@erase ".\debug\vc40.pdb"
+ -@erase ".\debug\vc40.idb"
+ -@erase ".\test_reactorEx.exe"
+ -@erase ".\debug\test_reactorEx.obj"
+ -@erase ".\test_reactorEx.ilk"
+ -@erase ".\test_reactorEx.pdb"
+
+"$(INTDIR)" :
+ if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
+
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
+CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE"\
+ /Fp"$(INTDIR)/ntalk.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
+CPP_OBJS=.\debug/
+CPP_SBRS=
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+BSC32_FLAGS=/nologo /o"$(OUTDIR)/ntalk.bsc"
+BSC32_SBRS=
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ace.lib /nologo /subsystem:console /debug /machine:I386 /out:"test_reactorEx.exe"
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
+ advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
+ odbccp32.lib ace.lib /nologo /subsystem:console /incremental:yes\
+ /pdb:"$(OUTDIR)/test_reactorEx.pdb" /debug /machine:I386\
+ /out:"$(OUTDIR)/test_reactorEx.exe"
+LINK32_OBJS= \
+ "$(INTDIR)/test_reactorEx.obj"
+
+"$(OUTDIR)\test_reactorEx.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ELSEIF "$(CFG)" == "test_remove_handler - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "test_remove_handler\Release"
+# PROP BASE Intermediate_Dir "test_remove_handler\Release"
+# PROP BASE Target_Dir "test_remove_handler"
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "test_remove_handler\Release"
+# PROP Intermediate_Dir "test_remove_handler\Release"
+# PROP Target_Dir "test_remove_handler"
+OUTDIR=.\test_remove_handler\Release
+INTDIR=.\test_remove_handler\Release
+
+ALL : "$(OUTDIR)\test_remove_handler.exe"
+
+CLEAN :
+ -@erase ".\test_remove_handler\Release\test_remove_handler.exe"
+ -@erase ".\test_remove_handler\Release\test_remove_handler.obj"
+
+"$(OUTDIR)" :
+ if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
+# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
+CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\
+ /Fp"$(INTDIR)/test_remove_handler.pch" /YX /Fo"$(INTDIR)/" /c
+CPP_OBJS=.\test_remove_handler\Release/
+CPP_SBRS=
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+BSC32_FLAGS=/nologo /o"$(OUTDIR)/test_remove_handler.bsc"
+BSC32_SBRS=
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
+ advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
+ odbccp32.lib /nologo /subsystem:console /incremental:no\
+ /pdb:"$(OUTDIR)/test_remove_handler.pdb" /machine:I386\
+ /out:"$(OUTDIR)/test_remove_handler.exe"
+LINK32_OBJS= \
+ "$(INTDIR)/test_remove_handler.obj"
+
+"$(OUTDIR)\test_remove_handler.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ELSEIF "$(CFG)" == "test_remove_handler - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "test_remove_handler\Debug"
+# PROP BASE Intermediate_Dir "test_remove_handler\Debug"
+# PROP BASE Target_Dir "test_remove_handler"
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir "test_remove_handler"
+OUTDIR=.
+INTDIR=.\Debug
+
+ALL : "$(OUTDIR)\test_remove_handler.exe"
+
+CLEAN :
+ -@erase ".\debug\vc40.pdb"
+ -@erase ".\debug\vc40.idb"
+ -@erase ".\test_remove_handler.exe"
+ -@erase ".\Debug\test_remove_handler.obj"
+ -@erase ".\test_remove_handler.ilk"
+ -@erase ".\test_remove_handler.pdb"
+
+"$(INTDIR)" :
+ if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
+
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
+# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
+CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE"\
+ /Fp"$(INTDIR)/test_remove_handler.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
+CPP_OBJS=.\Debug/
+CPP_SBRS=
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+BSC32_FLAGS=/nologo /o"$(OUTDIR)/test_remove_handler.bsc"
+BSC32_SBRS=
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ace.lib /nologo /subsystem:console /debug /machine:I386
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
+ advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
+ odbccp32.lib ace.lib /nologo /subsystem:console /incremental:yes\
+ /pdb:"$(OUTDIR)/test_remove_handler.pdb" /debug /machine:I386\
+ /out:"$(OUTDIR)/test_remove_handler.exe"
+LINK32_OBJS= \
+ "$(INTDIR)/test_remove_handler.obj"
+
+"$(OUTDIR)\test_remove_handler.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ENDIF
+
+.c{$(CPP_OBJS)}.obj:
+ $(CPP) $(CPP_PROJ) $<
+
+.cpp{$(CPP_OBJS)}.obj:
+ $(CPP) $(CPP_PROJ) $<
+
+.cxx{$(CPP_OBJS)}.obj:
+ $(CPP) $(CPP_PROJ) $<
+
+.c{$(CPP_SBRS)}.sbr:
+ $(CPP) $(CPP_PROJ) $<
+
+.cpp{$(CPP_SBRS)}.sbr:
+ $(CPP) $(CPP_PROJ) $<
+
+.cxx{$(CPP_SBRS)}.sbr:
+ $(CPP) $(CPP_PROJ) $<
+
+################################################################################
+# Begin Target
+
+# Name "ntalk - Win32 Release"
+# Name "ntalk - Win32 Debug"
+
+!IF "$(CFG)" == "ntalk - Win32 Release"
+
+!ELSEIF "$(CFG)" == "ntalk - Win32 Debug"
+
+!ENDIF
+
+################################################################################
+# Begin Source File
+
+SOURCE=.\test_reactorEx.cpp
+DEP_CPP_TEST_=\
+ {$(INCLUDE)}"\ace\ReactorEx.h"\
+ {$(INCLUDE)}"\ace\Proactor.h"\
+ {$(INCLUDE)}"\ace\SOCK_Connector.h"\
+ {$(INCLUDE)}"\ace\SOCK_Acceptor.h"\
+ {$(INCLUDE)}"\ace\Get_Opt.h"\
+ {$(INCLUDE)}"\ace\Time_Value.h"\
+ {$(INCLUDE)}"\ace\Service_Config.h"\
+ {$(INCLUDE)}"\ace\Synch.h"\
+ {$(INCLUDE)}"\ace\Task.h"\
+ {$(INCLUDE)}"\ace\OS.h"\
+ {$(INCLUDE)}"\ace\Timer_Queue.h"\
+ {$(INCLUDE)}"\ace\Event_Handler.h"\
+ {$(INCLUDE)}"\ace\Token.h"\
+ {$(INCLUDE)}"\ace\Local_Tokens.h"\
+ {$(INCLUDE)}"\ace\ReactorEx.i"\
+ {$(INCLUDE)}"\ace\Timer_Queue.i"\
+ {$(INCLUDE)}"\ace\ACE.h"\
+ {$(INCLUDE)}"\ace\Event_Handler.i"\
+ {$(INCLUDE)}"\ace\ACE.i"\
+ {$(INCLUDE)}"\ace\Log_Msg.h"\
+ {$(INCLUDE)}"\ace\Log_Record.h"\
+ {$(INCLUDE)}"\ace\Log_Priority.h"\
+ {$(INCLUDE)}"\ace\Log_Record.i"\
+ {$(INCLUDE)}"\ace\Token.i"\
+ {$(INCLUDE)}"\ace\Stack.h"\
+ {$(INCLUDE)}"\ace\Synch_Options.h"\
+ {$(INCLUDE)}"\ace\Map_Manager.h"\
+ {$(INCLUDE)}"\ace\Local_Tokens.i"\
+ {$(INCLUDE)}"\ace\Stack.i"\
+ {$(INCLUDE)}"\ace\Stack.cpp"\
+ {$(INCLUDE)}"\ace\Map_Manager.i"\
+ {$(INCLUDE)}"\ace\Map_Manager.cpp"\
+ {$(INCLUDE)}"\ace\Malloc.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Simple.h"\
+ {$(INCLUDE)}"\ace\Malloc.i"\
+ {$(INCLUDE)}"\ace\Malloc_T.h"\
+ {$(INCLUDE)}"\ace\Memory_Pool.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Simple.i"\
+ {$(INCLUDE)}"\ace\Trace.h"\
+ {$(INCLUDE)}"\ace\Malloc_T.i"\
+ {$(INCLUDE)}"\ace\Malloc_T.cpp"\
+ {$(INCLUDE)}"\ace\Signal.h"\
+ {$(INCLUDE)}"\ace\Mem_Map.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Complex.h"\
+ {$(INCLUDE)}"\ace\Memory_Pool.i"\
+ {$(INCLUDE)}"\ace\Set.h"\
+ {$(INCLUDE)}"\ace\Signal.i"\
+ {$(INCLUDE)}"\ace\Set.i"\
+ {$(INCLUDE)}"\ace\Set.cpp"\
+ {$(INCLUDE)}"\ace\Mem_Map.i"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Complex.i"\
+ {$(INCLUDE)}"\ace\Message_Block.h"\
+ {$(INCLUDE)}"\ace\Proactor.i"\
+ {$(INCLUDE)}"\ace\Message_Block.i"\
+ {$(INCLUDE)}"\ace\SOCK_Stream.h"\
+ {$(INCLUDE)}"\ace\SOCK_Connector.i"\
+ {$(INCLUDE)}"\ace\SOCK_IO.h"\
+ {$(INCLUDE)}"\ace\INET_Addr.h"\
+ {$(INCLUDE)}"\ace\SOCK_Stream.i"\
+ {$(INCLUDE)}"\ace\SOCK.h"\
+ {$(INCLUDE)}"\ace\SOCK_IO.i"\
+ {$(INCLUDE)}"\ace\Addr.h"\
+ {$(INCLUDE)}"\ace\IPC_SAP.h"\
+ {$(INCLUDE)}"\ace\SOCK.i"\
+ {$(INCLUDE)}"\ace\Addr.i"\
+ {$(INCLUDE)}"\ace\IPC_SAP.i"\
+ {$(INCLUDE)}"\ace\INET_Addr.i"\
+ {$(INCLUDE)}"\ace\SOCK_Acceptor.i"\
+ {$(INCLUDE)}"\ace\Get_Opt.i"\
+ {$(INCLUDE)}"\ace\config.h"\
+ {$(INCLUDE)}"\ace\Time_Value.i"\
+ {$(INCLUDE)}"\ace\Service_Object.h"\
+ {$(INCLUDE)}"\ace\Thread_Manager.h"\
+ {$(INCLUDE)}"\ace\Service_Config.i"\
+ {$(INCLUDE)}"\ace\Reactor.h"\
+ {$(INCLUDE)}"\ace\Svc_Conf_Tokens.h"\
+ {$(INCLUDE)}"\ace\Shared_Object.h"\
+ {$(INCLUDE)}"\ace\Service_Object.i"\
+ {$(INCLUDE)}"\ace\Shared_Object.i"\
+ {$(INCLUDE)}"\ace\Thread.h"\
+ {$(INCLUDE)}"\ace\Thread_Manager.i"\
+ {$(INCLUDE)}"\ace\Thread.i"\
+ {$(INCLUDE)}"\ace\Handle_Set.h"\
+ {$(INCLUDE)}"\ace\Pipe.h"\
+ {$(INCLUDE)}"\ace\Reactor.i"\
+ {$(INCLUDE)}"\ace\Handle_Set.i"\
+ {$(INCLUDE)}"\ace\Pipe.i"\
+ {$(INCLUDE)}"\ace\Synch.i"\
+ {$(INCLUDE)}"\ace\Synch_T.h"\
+ {$(INCLUDE)}"\ace\Synch_T.i"\
+ {$(INCLUDE)}"\ace\Synch_T.cpp"\
+ {$(INCLUDE)}"\ace\Message_Queue.h"\
+ {$(INCLUDE)}"\ace\Task.i"\
+ {$(INCLUDE)}"\ace\Task.cpp"\
+ {$(INCLUDE)}"\ace\IO_Cntl_Msg.h"\
+ {$(INCLUDE)}"\ace\Message_Queue.i"\
+ {$(INCLUDE)}"\ace\Message_Queue.cpp"\
+ {$(INCLUDE)}"\ace\Module.h"\
+ {$(INCLUDE)}"\ace\Module.i"\
+ {$(INCLUDE)}"\ace\Module.cpp"\
+ {$(INCLUDE)}"\ace\Stream_Modules.h"\
+ {$(INCLUDE)}"\ace\Stream_Modules.i"\
+ {$(INCLUDE)}"\ace\Stream_Modules.cpp"\
+ {$(INCLUDE)}"\sys\TYPES.H"\
+ {$(INCLUDE)}"\sys\STAT.H"\
+ {$(INCLUDE)}"\sys\TIMEB.H"\
+ {$(INCLUDE)}"\ace\OS.i"\
+
+NODEP_CPP_TEST_=\
+ ".\..\..\ace\ace\Sync_T.h"\
+ ".\..\..\ace\semLib.h"\
+
+
+"$(INTDIR)\test_reactorEx.obj" : $(SOURCE) $(DEP_CPP_TEST_) "$(INTDIR)"
+
+
+# End Source File
+# End Target
+################################################################################
+# Begin Target
+
+# Name "test_remove_handler - Win32 Release"
+# Name "test_remove_handler - Win32 Debug"
+
+!IF "$(CFG)" == "test_remove_handler - Win32 Release"
+
+!ELSEIF "$(CFG)" == "test_remove_handler - Win32 Debug"
+
+!ENDIF
+
+################################################################################
+# Begin Source File
+
+SOURCE=.\test_remove_handler.cpp
+DEP_CPP_TEST_R=\
+ {$(INCLUDE)}"\ace\ReactorEx.h"\
+ {$(INCLUDE)}"\ace\Service_Config.h"\
+ {$(INCLUDE)}"\ace\Synch.h"\
+ {$(INCLUDE)}"\ace\Timer_Queue.h"\
+ {$(INCLUDE)}"\ace\Time_Value.h"\
+ {$(INCLUDE)}"\ace\Event_Handler.h"\
+ {$(INCLUDE)}"\ace\Token.h"\
+ {$(INCLUDE)}"\ace\Local_Tokens.h"\
+ {$(INCLUDE)}"\ace\ReactorEx.i"\
+ {$(INCLUDE)}"\ace\Timer_Queue.i"\
+ {$(INCLUDE)}"\ace\config.h"\
+ {$(INCLUDE)}"\ace\Time_Value.i"\
+ {$(INCLUDE)}"\ace\Trace.h"\
+ {$(INCLUDE)}"\ace\ACE.h"\
+ {$(INCLUDE)}"\ace\Event_Handler.i"\
+ {$(INCLUDE)}"\ace\OS.h"\
+ {$(INCLUDE)}"\ace\ACE.i"\
+ {$(INCLUDE)}"\sys\TYPES.H"\
+ {$(INCLUDE)}"\sys\STAT.H"\
+ {$(INCLUDE)}"\sys\TIMEB.H"\
+ {$(INCLUDE)}"\ace\OS.i"\
+ {$(INCLUDE)}"\ace\Log_Msg.h"\
+ {$(INCLUDE)}"\ace\Log_Record.h"\
+ {$(INCLUDE)}"\ace\Log_Priority.h"\
+ {$(INCLUDE)}"\ace\Log_Record.i"\
+ {$(INCLUDE)}"\ace\Token.i"\
+ {$(INCLUDE)}"\ace\Stack.h"\
+ {$(INCLUDE)}"\ace\Synch_Options.h"\
+ {$(INCLUDE)}"\ace\Map_Manager.h"\
+ {$(INCLUDE)}"\ace\Local_Tokens.i"\
+ {$(INCLUDE)}"\ace\Stack.i"\
+ {$(INCLUDE)}"\ace\Stack.cpp"\
+ {$(INCLUDE)}"\ace\Map_Manager.i"\
+ {$(INCLUDE)}"\ace\Map_Manager.cpp"\
+ {$(INCLUDE)}"\ace\Malloc.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Simple.h"\
+ {$(INCLUDE)}"\ace\Malloc.i"\
+ {$(INCLUDE)}"\ace\Malloc_T.h"\
+ {$(INCLUDE)}"\ace\Memory_Pool.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Simple.i"\
+ {$(INCLUDE)}"\ace\Malloc_T.i"\
+ {$(INCLUDE)}"\ace\Malloc_T.cpp"\
+ {$(INCLUDE)}"\ace\Signal.h"\
+ {$(INCLUDE)}"\ace\Mem_Map.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Complex.h"\
+ {$(INCLUDE)}"\ace\Memory_Pool.i"\
+ {$(INCLUDE)}"\ace\Set.h"\
+ {$(INCLUDE)}"\ace\Signal.i"\
+ {$(INCLUDE)}"\ace\Set.i"\
+ {$(INCLUDE)}"\ace\Set.cpp"\
+ {$(INCLUDE)}"\ace\Mem_Map.i"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Complex.i"\
+ {$(INCLUDE)}"\ace\Service_Object.h"\
+ {$(INCLUDE)}"\ace\Thread_Manager.h"\
+ {$(INCLUDE)}"\ace\Proactor.h"\
+ {$(INCLUDE)}"\ace\Service_Config.i"\
+ {$(INCLUDE)}"\ace\Reactor.h"\
+ {$(INCLUDE)}"\ace\Svc_Conf_Tokens.h"\
+ {$(INCLUDE)}"\ace\Shared_Object.h"\
+ {$(INCLUDE)}"\ace\Service_Object.i"\
+ {$(INCLUDE)}"\ace\Shared_Object.i"\
+ {$(INCLUDE)}"\ace\Thread.h"\
+ {$(INCLUDE)}"\ace\Thread_Manager.i"\
+ {$(INCLUDE)}"\ace\Thread.i"\
+ {$(INCLUDE)}"\ace\Message_Block.h"\
+ {$(INCLUDE)}"\ace\Proactor.i"\
+ {$(INCLUDE)}"\ace\Message_Block.i"\
+ {$(INCLUDE)}"\ace\Handle_Set.h"\
+ {$(INCLUDE)}"\ace\Pipe.h"\
+ {$(INCLUDE)}"\ace\SOCK_Stream.h"\
+ {$(INCLUDE)}"\ace\Reactor.i"\
+ {$(INCLUDE)}"\ace\Handle_Set.i"\
+ {$(INCLUDE)}"\ace\Pipe.i"\
+ {$(INCLUDE)}"\ace\SOCK_IO.h"\
+ {$(INCLUDE)}"\ace\INET_Addr.h"\
+ {$(INCLUDE)}"\ace\SOCK_Stream.i"\
+ {$(INCLUDE)}"\ace\SOCK.h"\
+ {$(INCLUDE)}"\ace\SOCK_IO.i"\
+ {$(INCLUDE)}"\ace\Addr.h"\
+ {$(INCLUDE)}"\ace\IPC_SAP.h"\
+ {$(INCLUDE)}"\ace\SOCK.i"\
+ {$(INCLUDE)}"\ace\Addr.i"\
+ {$(INCLUDE)}"\ace\IPC_SAP.i"\
+ {$(INCLUDE)}"\ace\INET_Addr.i"\
+ {$(INCLUDE)}"\ace\Synch.i"\
+ {$(INCLUDE)}"\ace\Synch_T.h"\
+ {$(INCLUDE)}"\ace\Synch_T.i"\
+ {$(INCLUDE)}"\ace\Synch_T.cpp"\
+
+NODEP_CPP_TEST_R=\
+ ".\..\..\ace\semLib.h"\
+ ".\..\..\ace\ace\Sync_T.h"\
+
+
+"$(INTDIR)\test_remove_handler.obj" : $(SOURCE) $(DEP_CPP_TEST_R) "$(INTDIR)"
+
+
+# End Source File
+# End Target
+# End Project
+################################################################################
diff --git a/examples/Reactor/ReactorEx/reactorex.mdp b/examples/Reactor/ReactorEx/reactorex.mdp Binary files differnew file mode 100644 index 00000000000..0135cc67b75 --- /dev/null +++ b/examples/Reactor/ReactorEx/reactorex.mdp diff --git a/examples/Reactor/ReactorEx/test_reactorEx.cpp b/examples/Reactor/ReactorEx/test_reactorEx.cpp new file mode 100644 index 00000000000..757e78c1e9e --- /dev/null +++ b/examples/Reactor/ReactorEx/test_reactorEx.cpp @@ -0,0 +1,444 @@ +// ============================================================================ +// @(#)test_reactorEx.cpp 1.1 10/18/96 + +// +// = LIBRARY +// examples +// +// = FILENAME +// test_reactorEx.cpp +// +// = DESCRIPTION +// This test application tests a wide range of events that can be +// demultiplexed using various ACE utilities. Events used include ^C +// events, reading from STDIN, vanilla Win32 events, thread exits, +// ReactorEx notifications, proactive reads, and proactive writes. +// +// The proactive I/O events are demultiplexed by the ACE_Proactor. +// The thread exits, notications, and vanilla Win32 events are +// demultiplexed by the ACE_ReactorEx. To enable a single thread +// to run all these events, the Proactor is integrated with the +// ReactorEx. +// +// = AUTHOR +// Tim Harrison +// +// ============================================================================ + +#include "ace/ReactorEx.h" +#include "ace/Proactor.h" +#include "ace/SOCK_Connector.h" +#include "ace/SOCK_Acceptor.h" +#include "ace/Get_Opt.h" +#include "ace/Time_Value.h" +#include "ace/Service_Config.h" +#include "ace/Synch.h" +#include "ace/Task.h" +#include "ace/OS.h" + +typedef ACE_Task<ACE_MT_SYNCH> MT_TASK; + +class Peer_Handler : public MT_TASK + // = TITLE + // Connect to a server. Receive messages from STDIN_Handler + // and forward them to the server using proactive I/O. +{ +public: + Peer_Handler (int argc, char *argv[]); + + int open (void * =0); + // This method creates the network connection to the remote peer. + // It does blocking connects and accepts depending on whether a + // hostname was specified from the command line. + + virtual int handle_output_complete (ACE_Message_Block *msg, + long bytes_transfered); + // One of our asynchronous writes to the remote peer has completed. + // Make sure it succeeded and then delete the message. + + virtual int handle_input_complete (ACE_Message_Block *msg, + long bytes_transfered); + // The remote peer has sent us something. If it succeeded, print + // out the message and reinitiate a read. Otherwise, fail. In both + // cases, delete the message sent. + + virtual ACE_Message_Block *get_message (void); + // This is so the Proactor can get a message to read into. + + virtual ACE_HANDLE get_handle (void) const; + // This is so the Proactor can get our handle. + + virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask); + // We've been removed from the ReactorEx. + + virtual int handle_signal (int index, siginfo_t *, ucontext_t *); + // We've been signaled by the STDIN thread. Try to dequeue a + // message. + + void try_send (void); + // Try to dequeue a message. If successful, send it proactively to + // the remote peer. + + virtual int put (ACE_Message_Block *mb, + ACE_Time_Value *tv = 0); + // Enqueue the new mb and signal the main thread. + +private: + ACE_SOCK_Stream stream_; + // Socket that we have connected to the server. + + ACE_HANDLE new_msg_event_; + // Event that gets signaled when messages arrive. + + // = Remote peer info. + char *host_; + // Name of remote host. + + u_short port_; + // Port number for remote host. + + // = Make Task happy. + int close (u_long) { return 0; } +}; + +class STDIN_Handler : public ACE_Task<ACE_NULL_SYNCH> + // = TITLE + // Active Object. Reads from STDIN and passes message blocks to + // the peer handler. +{ +public: + STDIN_Handler (MT_TASK &ph); + + virtual int open (void * = 0); + // Activate object. + + virtual int close (u_long = 0); + // Shut down. + + int svc (void); + // Thread runs here. + +private: + MT_TASK &ph_; + // Send all input to ph_. + + static void handler (int signum); + // Handle a ^C. (Do nothing). + + int put (ACE_Message_Block *, ACE_Time_Value *) { return 0; } + // Make Task happy. + + void register_thread_exit_hook (void); + // Helper function to register with the ReactorEx for thread exit. + + virtual int handle_signal (int index, siginfo_t *, ucontext_t *); + // The STDIN thread has exited. This means the user hit ^C. We can + // end the event loop. +}; + +Peer_Handler::Peer_Handler (int argc, char *argv[]) + : host_ (0), + port_ (ACE_DEFAULT_SERVER_PORT) +{ + ACE_Get_Opt get_opt (argc, argv, "h:p:"); + int c; + + while ((c = get_opt ()) != EOF) + { + switch (c) + { + case 'h': + host_ = get_opt.optarg; + break; + case 'p': + port_ = ACE_OS::atoi (get_opt.optarg); + break; + } + } + + // Auto reset event. + new_msg_event_ = ::CreateEvent (NULL, FALSE, FALSE, NULL); + ACE_Service_Config::reactorEx ()-> + register_handler (this, new_msg_event_); +} + +// This method creates the network connection to the remote peer. It +// does blocking connects and accepts depending on whether a hostname +// was specified from the command line. + +int +Peer_Handler::open (void *) +{ + if (host_ != 0) // Connector + { + ACE_INET_Addr addr (port_, host_); + ACE_SOCK_Connector connector; + + // Establish connection with server. + if (connector.connect (stream_, addr) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "connect"), -1); + + ACE_DEBUG ((LM_DEBUG, "connected.\n")); + } + else // Acceptor + { + ACE_SOCK_Acceptor acceptor; + ACE_INET_Addr local_addr (port_); + + if ((acceptor.open (local_addr) == -1) || + (acceptor.accept (this->stream_) == -1)) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "accept failed"), -1); + + ACE_DEBUG ((LM_DEBUG, "accepted.\n")); + } + + return ACE_Service_Config::proactor ()->initiate + (this, ACE_Event_Handler::READ_MASK); +} + +// One of our asynchronous writes to the remote peer has completed. +// Make sure it succeeded and then delete the message. + +int +Peer_Handler::handle_output_complete (ACE_Message_Block *msg, + long bytes_transfered) +{ + if (bytes_transfered <= 0) + ACE_DEBUG ((LM_DEBUG, "%p bytes = %d\n", "Message failed", + bytes_transfered)); + + // This was allocated by the STDIN_Handler, queued, dequeued, + // passed to the proactor, and now passed back to us. + delete msg; + return 0; // Do not reinvoke a send. +} + +// The remote peer has sent us something. If it succeeded, print +// out the message and reinitiate a read. Otherwise, fail. In both +// cases, delete the message sent. + +int +Peer_Handler::handle_input_complete (ACE_Message_Block *msg, + long bytes_transfered) +{ + if ((bytes_transfered > 0) && (msg->length () > 0)) + { + msg->rd_ptr ()[bytes_transfered] = '\0'; + // Print out the message received from the server. + ACE_DEBUG ((LM_DEBUG, "%s", msg->rd_ptr ())); + delete msg; + return 1; // Reinvokes the recv() operation! + } + + delete msg; + // If a read failed, we will assume it's because the remote peer + // went away. We will end the event loop. Since we're in the main + // thread, we don't need to do a notify. + ACE_Service_Config::end_reactorEx_event_loop (); + return -1; // Close down. +} + +// This is so the Proactor can get a message to read into. + +ACE_Message_Block * +Peer_Handler::get_message (void) +{ + // An extra byte for NUL termination. + ACE_Message_Block *message = + new ACE_Message_Block (BUFSIZ + 1); + + message->size (BUFSIZ); + return message; +} + +// This is so the Proactor can get our handle. +ACE_HANDLE +Peer_Handler::get_handle (void) const +{ + return this->stream_.get_handle (); +} + +// We've been removed from the ReactorEx. +int +Peer_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) +{ + ACE_DEBUG ((LM_DEBUG, "Peer_Handler closing down\n")); + return 0; +} + +// We've been signaled by the STDIN thread. Try to dequeue a +// message. + +int +Peer_Handler::handle_signal (int, siginfo_t *, ucontext_t *) +{ + this->try_send (); + return 0; +} + +// Try to dequeue a message. If successful, send it proactively to +// the remote peer. + +void +Peer_Handler::try_send (void) +{ + ACE_Message_Block *mb; + + ACE_Time_Value tv (ACE_Time_Value::zero); + + if (this->getq (mb, &tv) != -1) + { + if (ACE_Service_Config::proactor ()-> + initiate (this, ACE_Event_Handler::WRITE_MASK, mb) == -1) + ACE_ERROR ((LM_ERROR, "%p Write initiate.\n", "Peer_Handler")); + } +} + +// Enqueue the new mb and signal the main thread. + +int +Peer_Handler::put (ACE_Message_Block *mb, ACE_Time_Value *tv) +{ + // Enqueue the mb. + int result = this->putq (mb, tv); + + // Signal the main thread. This will remain signaled until the main + // thread wakes up. + + if (::SetEvent (new_msg_event_) == 0) + ACE_ERROR ((LM_ERROR, "Pulse Failed!\n")); + + return result; +} + +void +STDIN_Handler::handler (int signum) +{ + ACE_DEBUG ((LM_DEBUG, "signal = %S\n", signum)); +} + +STDIN_Handler::STDIN_Handler (MT_TASK &ph) + : ph_ (ph) +{ + // Register for ^C from the console. We just need to catch the + // exception so that the kernel doesn't kill our process. + // Registering this signal handler just tells the kernel that we + // know what we're doing; to leave us alone. + ACE_OS::signal (SIGINT, ACE_SignalHandler (STDIN_Handler::handler)); +}; + +// Activate object. + +int +STDIN_Handler::open (void *) +{ + if (this->activate (THR_NEW_LWP | THR_DETACHED) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), -1); + + return 0; +} + +// Shut down. + +int +STDIN_Handler::close (u_long) +{ + ACE_DEBUG ((LM_DEBUG, "(%t) thread is exiting.\n")); + return 0; +} + +// Thread runs here. + +int +STDIN_Handler::svc (void) +{ + this->register_thread_exit_hook (); + + for (;;) + { + ACE_Message_Block *mb = new ACE_Message_Block (BUFSIZ); + + // Read from stdin into mb. + int read_result = ACE_OS::read (ACE_STDIN, + mb->rd_ptr (), + mb->size ()); + + // If read succeeds, put mb to peer handler, else end the loop. + if (read_result > 0) + { + mb->wr_ptr (read_result); + this->ph_.put (mb); + } + else + break; + } + + // handle_signal will get called. + return 42; +} + +// Register an exit hook with the reactorEx. All this junk is testing +// out how ACE_Thread::self (hthread_id&) doesn't work!! + +void +STDIN_Handler::register_thread_exit_hook (void) +{ + ACE_hthread_t handle; + + // Get a real handle to our thread. + ACE_Service_Config::thr_mgr ()->thr_self (handle); + + // Register ourselves to get called back when our thread exits. + + if (ACE_Service_Config::reactorEx ()-> + register_handler (this, handle) == -1) + ACE_ERROR ((LM_ERROR, "Exit_Hook Register failed.\n")); + + // We're in another thread, so we need to notify the ReactorEx so + // that it wakes up and waits on the new set of handles. + ACE_Service_Config::reactorEx ()->notify (); +} + +// The STDIN thread has exited. This means the user hit ^C. We can +// end the event loop and delete ourself. + +int +STDIN_Handler::handle_signal (int, siginfo_t *, ucontext_t *) +{ + ACE_DEBUG ((LM_DEBUG, "STDIN thread has exited.\n")); + ACE_Service_Config::end_reactorEx_event_loop (); + return 0; +} + +int +main (int argc, char *argv[]) +{ + // Open handler for remote peer communications this will run from + // the main thread. + Peer_Handler peer_handler (argc, argv); + + if (peer_handler.open () == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "%p open failed, errno = %d.\n", + "peer_handler", errno), 0); + + // Open active object for reading from stdin. + STDIN_Handler stdin_handler (peer_handler); + + if (stdin_handler.open () == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "%p open failed, errno = %d.\n", + "stdin_handler", errno), 0); + + // Register proactor with ReactorEx so that we can demultiplex + // "waitable" events and I/O operations from a single thread. + if (ACE_Service_Config::reactorEx ()->register_handler + (ACE_Service_Config::proactor ()) != 0) + ACE_ERROR_RETURN ((LM_ERROR, "%p failed to register Proactor.\n", + argv[0]), -1); + + // Run main event demultiplexor. + ACE_Service_Config::run_reactorEx_event_loop (); + + return 42; +} diff --git a/examples/Reactor/ReactorEx/test_remove_handler.cpp b/examples/Reactor/ReactorEx/test_remove_handler.cpp new file mode 100644 index 00000000000..fb61519b1e9 --- /dev/null +++ b/examples/Reactor/ReactorEx/test_remove_handler.cpp @@ -0,0 +1,94 @@ +// ============================================================================ +// @(#)test_remove_handler.cpp 1.1 10/18/96 + +// +// = LIBRARY +// examples +// +// = FILENAME +// test_remove_handler.cpp +// +// = DESCRIPTION +// Tests the ReactorEx's ability to handle simultaneous events. If +// you pass anything on the command-line, then each handler +// requests to be removed from the ReactorEx after each event. +// This has a funky effect on the order in which handlers are +// serviced. So, if no parameters are passed in, the handlers +// should be serviced 1 through MAXIMUM_WAIT_OBJECTS. If handlers +// to request to be removed as signals occur, they will be serviced +// 1, MAX, MAX-1, ..., 2. This is because of a ReactorEx +// bookkeeping optimization. +// +// = AUTHOR +// Tim Harrison +// +// ============================================================================ + +#include "ace/ReactorEx.h" +#include "ace/Service_Config.h" +#include "ace/Synch.h" + +class Event_Handler : public ACE_Event_Handler +// = TITLE +// Generic Event Handler. +// +// = DESCRIPTION +// +// Creates event. Registers with ReactorEx. Signals event. If +// created with -close_down- it returns -1 from handle signal. +{ +public: + Event_Handler (int event_number, + int close_down) + : event_number_ (event_number), + close_down_ (close_down) + { + ACE_Service_Config::reactorEx ()->register_handler (this, + this->event_.handle ()); + this->event_.signal (); + } + + virtual int handle_signal (int index, siginfo_t *, ucontext_t *) + { + ACE_DEBUG ((LM_DEBUG, "event %d occured.\n", event_number_)); + + if (this->close_down_) + return -1; + else + return 0; + } + + virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask) + { + // ACE_DEBUG ((LM_DEBUG, "event handler %d closed.\n", event_number_)); + delete this; + return 0; + } + + virtual ACE_HANDLE get_handle (void) const + { + return event_.handle (); + } + +private: + int event_number_; + // Our event number. + + int close_down_; + // Shall we close down or not. + + ACE_Event event_; + // Signaled to shut down the handler. +}; + +int +main (int argc, char *argv[]) +{ + int close_down = arg > 1 ? 1 : 0; + + for (int i = 0; i < ACE_ReactorEx::MAX_SIZE; i++) + new Event_Handler (i, close_down); + + ACE_Service_Config::reactorEx ()->handle_events (); + return 42; +} diff --git a/examples/Reactor/WFMO_Reactor/README b/examples/Reactor/WFMO_Reactor/README new file mode 100644 index 00000000000..1184d09dd68 --- /dev/null +++ b/examples/Reactor/WFMO_Reactor/README @@ -0,0 +1,204 @@ +The ACE_ReactorEx encapsulates the Win32 WaitForMultipleObjects() API +within ACE. The ACE_ReactorEx is similar in spirit to the +ACE_Reactor, except that (1) it is much simpler and (2) it works for +the complete range of Win32 handles (whereas the ACE_Reactor just +works for socket handles. + +Here's the API for the ACE_ReactorEx: + +class ACE_ReactorEx +{ +public: + // = Event loop. + virtual int handle_events (ACE_Time_Value *); + + // = Handler registration management. + virtual int register_handler (ACE_Event_Handler *); + virtual int remove_handler (ACE_Event_Handler *); + + virtual int notify (void); + + // = Timer management + virtual int schedule_timer (), etc. + // ... +}; + +---------------------------------------- + +Here's how you might use it: + +---------------------------------------- + +class My_Thread_Handler : public ACE_Event_Handler +{ +public: + My_Thread_Handler (void) { + // Create a thread that will run + // for a time and then exit. + this->thread_handle_ = + ACE_OS::thr_create (run, ......); + } + + // Called back by the ACE_ReactorEx when the + // event is signaled. + virtual int handle_signal (int) + { + cout << "thread is done" << endl; + } + + virtual ACE_HANDLE get_handle (void) const + { + return this->thread_handle_; + } + +private: + ACE_HANDLE thread_handle_; + + static void *run (void *) { + // Sleep for a while and then exit. + ACE_OS::sleep (100000); + return 0; + } +}; + +---------------------------------------- + +The main program might look something like this: + +---------------------------------------- + +int main (void) +{ + // ... + ACE_ReactorEx dispatcher; + My_Thread_Handler handler; + + // Register the thread handler. + dispatcher.register_handler (&handler); + + // Block until the thread exits and the + // handle_signal() method of the My_Thread_Handler + // is called! + dispatcher.handle_events (); + + // ... +} + +---------------------------------------- + +. test_remove_handler -- + +This application tests the ReactorEx's ability to handle simultaneous +events. If you pass anything on the command-line, then each handler +requests to be removed from the ReactorEx after each event. This has +a funky effect on the order in which handlers are serviced. So, if no +parameters are passed in, the handlers should be serviced 1 through +MAXIMUM_WAIT_OBJECTS. If handlers to request to be removed as signals +occur, they will be serviced 1, MAX, MAX-1, ..., 2. This is because +of a ReactorEx bookkeeping optimization. + +. test_reactorEx.cpp -- + +This test application tests a wide range of events that can be +demultiplexed using various ACE utilities. Events used include ^C +events, reading from STDIN, vanilla Win32 events, thread exits, +ReactorEx notifications, proactive reads, and proactive writes. + +The proactive I/O events are demultiplexed by the ACE_Proactor. The +thread exits, notications, and vanilla Win32 events are demultiplexed +by the ACE_ReactorEx. To enable a single thread to run all these +events, the Proactor is integrated with the ReactorEx. + +The test application prototypes a simple ntalk program. Two instances +of the application connect. Input from either console is displayed on +the others console also. Because of the evils of Win32 STDIN, a +separate thread is used to read from STDIN. To test the Proactor and +ReactorEx, I/O between the remote processes is performed proactively +and interactions between the STDIN thread and the main thread are +performed reactively. + +The following description of the test application is in two parts. +The participants section explains the main components involved in the +application. The collaboration section describes how the partipants +interact in response to the multiple event types which occur. + +The ReactorEx test application has the following participants: + +. ReactorEx -- The ReactorEx demultiplexes Win32 "waitable" events + using WaitForMultipleObjects. + +. Proactor -- The proactor initiates and demultiplexes overlapped I/O + operations. The Proactor registers with the ReactorEx so that a + single-thread can demultiplex all application events. + +. STDIN_Handler -- STDIN_Handler is an Active Object which reads from + STDIN and forwards the input to the Peer_Handler. This runs + in a separate thread to make the test more interesting. However, + STDIN is "waitable", so in general it can be waited on by the ACE + ReactorEx, thanks MicroSlush! + +. Peer_Handler -- The Peer_Handler connects to another instance of + test_reactorEx. It Proactively reads and writes data to the peer. + When the STDIN_Handler gives it messages, it fowards them to the + remote peer. When it receives messages from the remote peer, it + prints the output to the console. + +The collaborations of the participants are as follows: + +. Initialization + + Peer_Handler -- connects to the remote peer. It then begins + proactively reading from the remote connection. Note that it will + be notified by the Proactor when a read completes. It also + registers a new_msg_event with the ReactorEx. Note that when the + new_msg_event is signaled (by the STDIN_Handler), + Peer_Handler::handle_signal will get called. + + STDIN_Handler -- STDIN_Handler registers a signal handler for + SIGINT. This just captures the exception so that the kernel doesn't + kill our process; We want to exit gracefully. It also creates an + Exit_Hook object which registers the STDIN_Handler's thread handle + with the ReactorEx. The Exit_Hook will get called back when the + STDIN_Handler thread exits. After registering these, it blocks + reading from STDIN. + + Proactor -- is registered with the ReactorEx. + + The main thread of control waits in the ReactorEx. + +. STDIN events -- When the STDIN_Handler thread reads from STDIN, it + puts the message on Peer_Handler's message queue and signals the + new_msg_event. It then returns to reading from STDIN. + +. new_msg_events -- The ReactorEx thread wakes up and calls + Peer_Handler::handle_signal. The Peer_Handler then tries to dequeue + a message from its message queue. If it can, the message is + Proactively sent to the remote peer. Note that the Peer_Handler + will be notified with this operation is complete. The Peer_Handler + then falls back into the ReactorEx event loop. + +. Send complete event -- When a proactive send is complete, the + Proactor is notified by the ReactorEx. The Proactor, in turn, + notifies the Peer_Handler. The Peer_Handler then checks for more + messages from the message queue. If there are any, it tries to send + them. If there are not, it returns to the ReactorEx event loop. + This is ok since it is notified via new_msg_event when new message + arrive. + +. Read complete event -- When a proactive read is complete (the + Peer_Handler initiated a proactive read when it connected to the + remote peer), the Proactor is notified by the ReactorEx. The + Proactor, in turn notifies the Peer_Handler. If the read was + successful the Peer_Handler just displays the received msg to the + console and reinvokes a proactive read from the network connection. + If the read failed (i.e. the remote peer exited), the Peer_Handler + sets a flag to end the event loop and returns. This will cause the + application to exit. + +. ^C events -- When the user types ^C at the console, the + STDIN_Handler's signal handler will be called. It does nothing, but + as a result of the signal, the STDIN_Handler thread will exit. + +. STDIN_Handler thread exits -- The Exit_Hook will get called back + from the ReactorEx. Exit_Hook::handle_signal sets a flag to end the + event loop and returns. This will cause the application to exit. diff --git a/examples/Reactor/WFMO_Reactor/reactorex.mak b/examples/Reactor/WFMO_Reactor/reactorex.mak new file mode 100644 index 00000000000..150d04508d7 --- /dev/null +++ b/examples/Reactor/WFMO_Reactor/reactorex.mak @@ -0,0 +1,535 @@ +# Microsoft Developer Studio Generated NMAKE File, Format Version 4.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+!IF "$(CFG)" == ""
+CFG=test_remove_handler - Win32 Debug
+!MESSAGE No configuration specified. Defaulting to test_remove_handler - Win32\
+ Debug.
+!ENDIF
+
+!IF "$(CFG)" != "ntalk - Win32 Release" && "$(CFG)" != "ntalk - Win32 Debug" &&\
+ "$(CFG)" != "test_remove_handler - Win32 Release" && "$(CFG)" !=\
+ "test_remove_handler - Win32 Debug"
+!MESSAGE Invalid configuration "$(CFG)" specified.
+!MESSAGE You can specify a configuration when running NMAKE on this makefile
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "reactorEx.mak" CFG="test_remove_handler - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "ntalk - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "ntalk - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE "test_remove_handler - Win32 Release" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE "test_remove_handler - Win32 Debug" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE
+!ERROR An invalid configuration is specified.
+!ENDIF
+
+!IF "$(OS)" == "Windows_NT"
+NULL=
+!ELSE
+NULL=nul
+!ENDIF
+################################################################################
+# Begin Project
+# PROP Target_Last_Scanned "ntalk - Win32 Debug"
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "ntalk - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "ntalk\Release"
+# PROP BASE Intermediate_Dir "ntalk\Release"
+# PROP BASE Target_Dir "ntalk"
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "ntalk\Release"
+# PROP Intermediate_Dir "ntalk\Release"
+# PROP Target_Dir "ntalk"
+OUTDIR=.\ntalk\Release
+INTDIR=.\ntalk\Release
+
+ALL : "$(OUTDIR)\ntalk.exe"
+
+CLEAN :
+ -@erase ".\ntalk\Release\ntalk.exe"
+ -@erase ".\ntalk\Release\test_reactorEx.obj"
+
+"$(OUTDIR)" :
+ if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
+# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
+CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\
+ /Fp"$(INTDIR)/ntalk.pch" /YX /Fo"$(INTDIR)/" /c
+CPP_OBJS=.\ntalk\Release/
+CPP_SBRS=
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+BSC32_FLAGS=/nologo /o"$(OUTDIR)/ntalk.bsc"
+BSC32_SBRS=
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ace.lib /nologo /subsystem:console /machine:I386
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
+ advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
+ odbccp32.lib ace.lib /nologo /subsystem:console /incremental:no\
+ /pdb:"$(OUTDIR)/ntalk.pdb" /machine:I386 /out:"$(OUTDIR)/ntalk.exe"
+LINK32_OBJS= \
+ "$(INTDIR)/test_reactorEx.obj"
+
+"$(OUTDIR)\ntalk.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ELSEIF "$(CFG)" == "ntalk - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "ntalk\Debug"
+# PROP BASE Intermediate_Dir "ntalk\Debug"
+# PROP BASE Target_Dir "ntalk"
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "debug"
+# PROP Target_Dir "ntalk"
+OUTDIR=.
+INTDIR=.\debug
+
+ALL : "$(OUTDIR)\test_reactorEx.exe"
+
+CLEAN :
+ -@erase ".\debug\vc40.pdb"
+ -@erase ".\debug\vc40.idb"
+ -@erase ".\test_reactorEx.exe"
+ -@erase ".\debug\test_reactorEx.obj"
+ -@erase ".\test_reactorEx.ilk"
+ -@erase ".\test_reactorEx.pdb"
+
+"$(INTDIR)" :
+ if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
+
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
+CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE"\
+ /Fp"$(INTDIR)/ntalk.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
+CPP_OBJS=.\debug/
+CPP_SBRS=
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+BSC32_FLAGS=/nologo /o"$(OUTDIR)/ntalk.bsc"
+BSC32_SBRS=
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ace.lib /nologo /subsystem:console /debug /machine:I386 /out:"test_reactorEx.exe"
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
+ advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
+ odbccp32.lib ace.lib /nologo /subsystem:console /incremental:yes\
+ /pdb:"$(OUTDIR)/test_reactorEx.pdb" /debug /machine:I386\
+ /out:"$(OUTDIR)/test_reactorEx.exe"
+LINK32_OBJS= \
+ "$(INTDIR)/test_reactorEx.obj"
+
+"$(OUTDIR)\test_reactorEx.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ELSEIF "$(CFG)" == "test_remove_handler - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "test_remove_handler\Release"
+# PROP BASE Intermediate_Dir "test_remove_handler\Release"
+# PROP BASE Target_Dir "test_remove_handler"
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "test_remove_handler\Release"
+# PROP Intermediate_Dir "test_remove_handler\Release"
+# PROP Target_Dir "test_remove_handler"
+OUTDIR=.\test_remove_handler\Release
+INTDIR=.\test_remove_handler\Release
+
+ALL : "$(OUTDIR)\test_remove_handler.exe"
+
+CLEAN :
+ -@erase ".\test_remove_handler\Release\test_remove_handler.exe"
+ -@erase ".\test_remove_handler\Release\test_remove_handler.obj"
+
+"$(OUTDIR)" :
+ if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
+# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
+CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\
+ /Fp"$(INTDIR)/test_remove_handler.pch" /YX /Fo"$(INTDIR)/" /c
+CPP_OBJS=.\test_remove_handler\Release/
+CPP_SBRS=
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+BSC32_FLAGS=/nologo /o"$(OUTDIR)/test_remove_handler.bsc"
+BSC32_SBRS=
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
+ advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
+ odbccp32.lib /nologo /subsystem:console /incremental:no\
+ /pdb:"$(OUTDIR)/test_remove_handler.pdb" /machine:I386\
+ /out:"$(OUTDIR)/test_remove_handler.exe"
+LINK32_OBJS= \
+ "$(INTDIR)/test_remove_handler.obj"
+
+"$(OUTDIR)\test_remove_handler.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ELSEIF "$(CFG)" == "test_remove_handler - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "test_remove_handler\Debug"
+# PROP BASE Intermediate_Dir "test_remove_handler\Debug"
+# PROP BASE Target_Dir "test_remove_handler"
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir "test_remove_handler"
+OUTDIR=.
+INTDIR=.\Debug
+
+ALL : "$(OUTDIR)\test_remove_handler.exe"
+
+CLEAN :
+ -@erase ".\debug\vc40.pdb"
+ -@erase ".\debug\vc40.idb"
+ -@erase ".\test_remove_handler.exe"
+ -@erase ".\Debug\test_remove_handler.obj"
+ -@erase ".\test_remove_handler.ilk"
+ -@erase ".\test_remove_handler.pdb"
+
+"$(INTDIR)" :
+ if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
+
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
+# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
+CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE"\
+ /Fp"$(INTDIR)/test_remove_handler.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
+CPP_OBJS=.\Debug/
+CPP_SBRS=
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+BSC32_FLAGS=/nologo /o"$(OUTDIR)/test_remove_handler.bsc"
+BSC32_SBRS=
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ace.lib /nologo /subsystem:console /debug /machine:I386
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
+ advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
+ odbccp32.lib ace.lib /nologo /subsystem:console /incremental:yes\
+ /pdb:"$(OUTDIR)/test_remove_handler.pdb" /debug /machine:I386\
+ /out:"$(OUTDIR)/test_remove_handler.exe"
+LINK32_OBJS= \
+ "$(INTDIR)/test_remove_handler.obj"
+
+"$(OUTDIR)\test_remove_handler.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ENDIF
+
+.c{$(CPP_OBJS)}.obj:
+ $(CPP) $(CPP_PROJ) $<
+
+.cpp{$(CPP_OBJS)}.obj:
+ $(CPP) $(CPP_PROJ) $<
+
+.cxx{$(CPP_OBJS)}.obj:
+ $(CPP) $(CPP_PROJ) $<
+
+.c{$(CPP_SBRS)}.sbr:
+ $(CPP) $(CPP_PROJ) $<
+
+.cpp{$(CPP_SBRS)}.sbr:
+ $(CPP) $(CPP_PROJ) $<
+
+.cxx{$(CPP_SBRS)}.sbr:
+ $(CPP) $(CPP_PROJ) $<
+
+################################################################################
+# Begin Target
+
+# Name "ntalk - Win32 Release"
+# Name "ntalk - Win32 Debug"
+
+!IF "$(CFG)" == "ntalk - Win32 Release"
+
+!ELSEIF "$(CFG)" == "ntalk - Win32 Debug"
+
+!ENDIF
+
+################################################################################
+# Begin Source File
+
+SOURCE=.\test_reactorEx.cpp
+DEP_CPP_TEST_=\
+ {$(INCLUDE)}"\ace\ReactorEx.h"\
+ {$(INCLUDE)}"\ace\Proactor.h"\
+ {$(INCLUDE)}"\ace\SOCK_Connector.h"\
+ {$(INCLUDE)}"\ace\SOCK_Acceptor.h"\
+ {$(INCLUDE)}"\ace\Get_Opt.h"\
+ {$(INCLUDE)}"\ace\Time_Value.h"\
+ {$(INCLUDE)}"\ace\Service_Config.h"\
+ {$(INCLUDE)}"\ace\Synch.h"\
+ {$(INCLUDE)}"\ace\Task.h"\
+ {$(INCLUDE)}"\ace\OS.h"\
+ {$(INCLUDE)}"\ace\Timer_Queue.h"\
+ {$(INCLUDE)}"\ace\Event_Handler.h"\
+ {$(INCLUDE)}"\ace\Token.h"\
+ {$(INCLUDE)}"\ace\Local_Tokens.h"\
+ {$(INCLUDE)}"\ace\ReactorEx.i"\
+ {$(INCLUDE)}"\ace\Timer_Queue.i"\
+ {$(INCLUDE)}"\ace\ACE.h"\
+ {$(INCLUDE)}"\ace\Event_Handler.i"\
+ {$(INCLUDE)}"\ace\ACE.i"\
+ {$(INCLUDE)}"\ace\Log_Msg.h"\
+ {$(INCLUDE)}"\ace\Log_Record.h"\
+ {$(INCLUDE)}"\ace\Log_Priority.h"\
+ {$(INCLUDE)}"\ace\Log_Record.i"\
+ {$(INCLUDE)}"\ace\Token.i"\
+ {$(INCLUDE)}"\ace\Stack.h"\
+ {$(INCLUDE)}"\ace\Synch_Options.h"\
+ {$(INCLUDE)}"\ace\Map_Manager.h"\
+ {$(INCLUDE)}"\ace\Local_Tokens.i"\
+ {$(INCLUDE)}"\ace\Stack.i"\
+ {$(INCLUDE)}"\ace\Stack.cpp"\
+ {$(INCLUDE)}"\ace\Map_Manager.i"\
+ {$(INCLUDE)}"\ace\Map_Manager.cpp"\
+ {$(INCLUDE)}"\ace\Malloc.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Simple.h"\
+ {$(INCLUDE)}"\ace\Malloc.i"\
+ {$(INCLUDE)}"\ace\Malloc_T.h"\
+ {$(INCLUDE)}"\ace\Memory_Pool.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Simple.i"\
+ {$(INCLUDE)}"\ace\Trace.h"\
+ {$(INCLUDE)}"\ace\Malloc_T.i"\
+ {$(INCLUDE)}"\ace\Malloc_T.cpp"\
+ {$(INCLUDE)}"\ace\Signal.h"\
+ {$(INCLUDE)}"\ace\Mem_Map.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Complex.h"\
+ {$(INCLUDE)}"\ace\Memory_Pool.i"\
+ {$(INCLUDE)}"\ace\Set.h"\
+ {$(INCLUDE)}"\ace\Signal.i"\
+ {$(INCLUDE)}"\ace\Set.i"\
+ {$(INCLUDE)}"\ace\Set.cpp"\
+ {$(INCLUDE)}"\ace\Mem_Map.i"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Complex.i"\
+ {$(INCLUDE)}"\ace\Message_Block.h"\
+ {$(INCLUDE)}"\ace\Proactor.i"\
+ {$(INCLUDE)}"\ace\Message_Block.i"\
+ {$(INCLUDE)}"\ace\SOCK_Stream.h"\
+ {$(INCLUDE)}"\ace\SOCK_Connector.i"\
+ {$(INCLUDE)}"\ace\SOCK_IO.h"\
+ {$(INCLUDE)}"\ace\INET_Addr.h"\
+ {$(INCLUDE)}"\ace\SOCK_Stream.i"\
+ {$(INCLUDE)}"\ace\SOCK.h"\
+ {$(INCLUDE)}"\ace\SOCK_IO.i"\
+ {$(INCLUDE)}"\ace\Addr.h"\
+ {$(INCLUDE)}"\ace\IPC_SAP.h"\
+ {$(INCLUDE)}"\ace\SOCK.i"\
+ {$(INCLUDE)}"\ace\Addr.i"\
+ {$(INCLUDE)}"\ace\IPC_SAP.i"\
+ {$(INCLUDE)}"\ace\INET_Addr.i"\
+ {$(INCLUDE)}"\ace\SOCK_Acceptor.i"\
+ {$(INCLUDE)}"\ace\Get_Opt.i"\
+ {$(INCLUDE)}"\ace\config.h"\
+ {$(INCLUDE)}"\ace\Time_Value.i"\
+ {$(INCLUDE)}"\ace\Service_Object.h"\
+ {$(INCLUDE)}"\ace\Thread_Manager.h"\
+ {$(INCLUDE)}"\ace\Service_Config.i"\
+ {$(INCLUDE)}"\ace\Reactor.h"\
+ {$(INCLUDE)}"\ace\Svc_Conf_Tokens.h"\
+ {$(INCLUDE)}"\ace\Shared_Object.h"\
+ {$(INCLUDE)}"\ace\Service_Object.i"\
+ {$(INCLUDE)}"\ace\Shared_Object.i"\
+ {$(INCLUDE)}"\ace\Thread.h"\
+ {$(INCLUDE)}"\ace\Thread_Manager.i"\
+ {$(INCLUDE)}"\ace\Thread.i"\
+ {$(INCLUDE)}"\ace\Handle_Set.h"\
+ {$(INCLUDE)}"\ace\Pipe.h"\
+ {$(INCLUDE)}"\ace\Reactor.i"\
+ {$(INCLUDE)}"\ace\Handle_Set.i"\
+ {$(INCLUDE)}"\ace\Pipe.i"\
+ {$(INCLUDE)}"\ace\Synch.i"\
+ {$(INCLUDE)}"\ace\Synch_T.h"\
+ {$(INCLUDE)}"\ace\Synch_T.i"\
+ {$(INCLUDE)}"\ace\Synch_T.cpp"\
+ {$(INCLUDE)}"\ace\Message_Queue.h"\
+ {$(INCLUDE)}"\ace\Task.i"\
+ {$(INCLUDE)}"\ace\Task.cpp"\
+ {$(INCLUDE)}"\ace\IO_Cntl_Msg.h"\
+ {$(INCLUDE)}"\ace\Message_Queue.i"\
+ {$(INCLUDE)}"\ace\Message_Queue.cpp"\
+ {$(INCLUDE)}"\ace\Module.h"\
+ {$(INCLUDE)}"\ace\Module.i"\
+ {$(INCLUDE)}"\ace\Module.cpp"\
+ {$(INCLUDE)}"\ace\Stream_Modules.h"\
+ {$(INCLUDE)}"\ace\Stream_Modules.i"\
+ {$(INCLUDE)}"\ace\Stream_Modules.cpp"\
+ {$(INCLUDE)}"\sys\TYPES.H"\
+ {$(INCLUDE)}"\sys\STAT.H"\
+ {$(INCLUDE)}"\sys\TIMEB.H"\
+ {$(INCLUDE)}"\ace\OS.i"\
+
+NODEP_CPP_TEST_=\
+ ".\..\..\ace\ace\Sync_T.h"\
+ ".\..\..\ace\semLib.h"\
+
+
+"$(INTDIR)\test_reactorEx.obj" : $(SOURCE) $(DEP_CPP_TEST_) "$(INTDIR)"
+
+
+# End Source File
+# End Target
+################################################################################
+# Begin Target
+
+# Name "test_remove_handler - Win32 Release"
+# Name "test_remove_handler - Win32 Debug"
+
+!IF "$(CFG)" == "test_remove_handler - Win32 Release"
+
+!ELSEIF "$(CFG)" == "test_remove_handler - Win32 Debug"
+
+!ENDIF
+
+################################################################################
+# Begin Source File
+
+SOURCE=.\test_remove_handler.cpp
+DEP_CPP_TEST_R=\
+ {$(INCLUDE)}"\ace\ReactorEx.h"\
+ {$(INCLUDE)}"\ace\Service_Config.h"\
+ {$(INCLUDE)}"\ace\Synch.h"\
+ {$(INCLUDE)}"\ace\Timer_Queue.h"\
+ {$(INCLUDE)}"\ace\Time_Value.h"\
+ {$(INCLUDE)}"\ace\Event_Handler.h"\
+ {$(INCLUDE)}"\ace\Token.h"\
+ {$(INCLUDE)}"\ace\Local_Tokens.h"\
+ {$(INCLUDE)}"\ace\ReactorEx.i"\
+ {$(INCLUDE)}"\ace\Timer_Queue.i"\
+ {$(INCLUDE)}"\ace\config.h"\
+ {$(INCLUDE)}"\ace\Time_Value.i"\
+ {$(INCLUDE)}"\ace\Trace.h"\
+ {$(INCLUDE)}"\ace\ACE.h"\
+ {$(INCLUDE)}"\ace\Event_Handler.i"\
+ {$(INCLUDE)}"\ace\OS.h"\
+ {$(INCLUDE)}"\ace\ACE.i"\
+ {$(INCLUDE)}"\sys\TYPES.H"\
+ {$(INCLUDE)}"\sys\STAT.H"\
+ {$(INCLUDE)}"\sys\TIMEB.H"\
+ {$(INCLUDE)}"\ace\OS.i"\
+ {$(INCLUDE)}"\ace\Log_Msg.h"\
+ {$(INCLUDE)}"\ace\Log_Record.h"\
+ {$(INCLUDE)}"\ace\Log_Priority.h"\
+ {$(INCLUDE)}"\ace\Log_Record.i"\
+ {$(INCLUDE)}"\ace\Token.i"\
+ {$(INCLUDE)}"\ace\Stack.h"\
+ {$(INCLUDE)}"\ace\Synch_Options.h"\
+ {$(INCLUDE)}"\ace\Map_Manager.h"\
+ {$(INCLUDE)}"\ace\Local_Tokens.i"\
+ {$(INCLUDE)}"\ace\Stack.i"\
+ {$(INCLUDE)}"\ace\Stack.cpp"\
+ {$(INCLUDE)}"\ace\Map_Manager.i"\
+ {$(INCLUDE)}"\ace\Map_Manager.cpp"\
+ {$(INCLUDE)}"\ace\Malloc.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Simple.h"\
+ {$(INCLUDE)}"\ace\Malloc.i"\
+ {$(INCLUDE)}"\ace\Malloc_T.h"\
+ {$(INCLUDE)}"\ace\Memory_Pool.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Simple.i"\
+ {$(INCLUDE)}"\ace\Malloc_T.i"\
+ {$(INCLUDE)}"\ace\Malloc_T.cpp"\
+ {$(INCLUDE)}"\ace\Signal.h"\
+ {$(INCLUDE)}"\ace\Mem_Map.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Complex.h"\
+ {$(INCLUDE)}"\ace\Memory_Pool.i"\
+ {$(INCLUDE)}"\ace\Set.h"\
+ {$(INCLUDE)}"\ace\Signal.i"\
+ {$(INCLUDE)}"\ace\Set.i"\
+ {$(INCLUDE)}"\ace\Set.cpp"\
+ {$(INCLUDE)}"\ace\Mem_Map.i"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Complex.i"\
+ {$(INCLUDE)}"\ace\Service_Object.h"\
+ {$(INCLUDE)}"\ace\Thread_Manager.h"\
+ {$(INCLUDE)}"\ace\Proactor.h"\
+ {$(INCLUDE)}"\ace\Service_Config.i"\
+ {$(INCLUDE)}"\ace\Reactor.h"\
+ {$(INCLUDE)}"\ace\Svc_Conf_Tokens.h"\
+ {$(INCLUDE)}"\ace\Shared_Object.h"\
+ {$(INCLUDE)}"\ace\Service_Object.i"\
+ {$(INCLUDE)}"\ace\Shared_Object.i"\
+ {$(INCLUDE)}"\ace\Thread.h"\
+ {$(INCLUDE)}"\ace\Thread_Manager.i"\
+ {$(INCLUDE)}"\ace\Thread.i"\
+ {$(INCLUDE)}"\ace\Message_Block.h"\
+ {$(INCLUDE)}"\ace\Proactor.i"\
+ {$(INCLUDE)}"\ace\Message_Block.i"\
+ {$(INCLUDE)}"\ace\Handle_Set.h"\
+ {$(INCLUDE)}"\ace\Pipe.h"\
+ {$(INCLUDE)}"\ace\SOCK_Stream.h"\
+ {$(INCLUDE)}"\ace\Reactor.i"\
+ {$(INCLUDE)}"\ace\Handle_Set.i"\
+ {$(INCLUDE)}"\ace\Pipe.i"\
+ {$(INCLUDE)}"\ace\SOCK_IO.h"\
+ {$(INCLUDE)}"\ace\INET_Addr.h"\
+ {$(INCLUDE)}"\ace\SOCK_Stream.i"\
+ {$(INCLUDE)}"\ace\SOCK.h"\
+ {$(INCLUDE)}"\ace\SOCK_IO.i"\
+ {$(INCLUDE)}"\ace\Addr.h"\
+ {$(INCLUDE)}"\ace\IPC_SAP.h"\
+ {$(INCLUDE)}"\ace\SOCK.i"\
+ {$(INCLUDE)}"\ace\Addr.i"\
+ {$(INCLUDE)}"\ace\IPC_SAP.i"\
+ {$(INCLUDE)}"\ace\INET_Addr.i"\
+ {$(INCLUDE)}"\ace\Synch.i"\
+ {$(INCLUDE)}"\ace\Synch_T.h"\
+ {$(INCLUDE)}"\ace\Synch_T.i"\
+ {$(INCLUDE)}"\ace\Synch_T.cpp"\
+
+NODEP_CPP_TEST_R=\
+ ".\..\..\ace\semLib.h"\
+ ".\..\..\ace\ace\Sync_T.h"\
+
+
+"$(INTDIR)\test_remove_handler.obj" : $(SOURCE) $(DEP_CPP_TEST_R) "$(INTDIR)"
+
+
+# End Source File
+# End Target
+# End Project
+################################################################################
diff --git a/examples/Reactor/WFMO_Reactor/reactorex.mdp b/examples/Reactor/WFMO_Reactor/reactorex.mdp Binary files differnew file mode 100644 index 00000000000..0135cc67b75 --- /dev/null +++ b/examples/Reactor/WFMO_Reactor/reactorex.mdp diff --git a/examples/Reactor/WFMO_Reactor/test_reactorEx.cpp b/examples/Reactor/WFMO_Reactor/test_reactorEx.cpp new file mode 100644 index 00000000000..757e78c1e9e --- /dev/null +++ b/examples/Reactor/WFMO_Reactor/test_reactorEx.cpp @@ -0,0 +1,444 @@ +// ============================================================================ +// @(#)test_reactorEx.cpp 1.1 10/18/96 + +// +// = LIBRARY +// examples +// +// = FILENAME +// test_reactorEx.cpp +// +// = DESCRIPTION +// This test application tests a wide range of events that can be +// demultiplexed using various ACE utilities. Events used include ^C +// events, reading from STDIN, vanilla Win32 events, thread exits, +// ReactorEx notifications, proactive reads, and proactive writes. +// +// The proactive I/O events are demultiplexed by the ACE_Proactor. +// The thread exits, notications, and vanilla Win32 events are +// demultiplexed by the ACE_ReactorEx. To enable a single thread +// to run all these events, the Proactor is integrated with the +// ReactorEx. +// +// = AUTHOR +// Tim Harrison +// +// ============================================================================ + +#include "ace/ReactorEx.h" +#include "ace/Proactor.h" +#include "ace/SOCK_Connector.h" +#include "ace/SOCK_Acceptor.h" +#include "ace/Get_Opt.h" +#include "ace/Time_Value.h" +#include "ace/Service_Config.h" +#include "ace/Synch.h" +#include "ace/Task.h" +#include "ace/OS.h" + +typedef ACE_Task<ACE_MT_SYNCH> MT_TASK; + +class Peer_Handler : public MT_TASK + // = TITLE + // Connect to a server. Receive messages from STDIN_Handler + // and forward them to the server using proactive I/O. +{ +public: + Peer_Handler (int argc, char *argv[]); + + int open (void * =0); + // This method creates the network connection to the remote peer. + // It does blocking connects and accepts depending on whether a + // hostname was specified from the command line. + + virtual int handle_output_complete (ACE_Message_Block *msg, + long bytes_transfered); + // One of our asynchronous writes to the remote peer has completed. + // Make sure it succeeded and then delete the message. + + virtual int handle_input_complete (ACE_Message_Block *msg, + long bytes_transfered); + // The remote peer has sent us something. If it succeeded, print + // out the message and reinitiate a read. Otherwise, fail. In both + // cases, delete the message sent. + + virtual ACE_Message_Block *get_message (void); + // This is so the Proactor can get a message to read into. + + virtual ACE_HANDLE get_handle (void) const; + // This is so the Proactor can get our handle. + + virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask); + // We've been removed from the ReactorEx. + + virtual int handle_signal (int index, siginfo_t *, ucontext_t *); + // We've been signaled by the STDIN thread. Try to dequeue a + // message. + + void try_send (void); + // Try to dequeue a message. If successful, send it proactively to + // the remote peer. + + virtual int put (ACE_Message_Block *mb, + ACE_Time_Value *tv = 0); + // Enqueue the new mb and signal the main thread. + +private: + ACE_SOCK_Stream stream_; + // Socket that we have connected to the server. + + ACE_HANDLE new_msg_event_; + // Event that gets signaled when messages arrive. + + // = Remote peer info. + char *host_; + // Name of remote host. + + u_short port_; + // Port number for remote host. + + // = Make Task happy. + int close (u_long) { return 0; } +}; + +class STDIN_Handler : public ACE_Task<ACE_NULL_SYNCH> + // = TITLE + // Active Object. Reads from STDIN and passes message blocks to + // the peer handler. +{ +public: + STDIN_Handler (MT_TASK &ph); + + virtual int open (void * = 0); + // Activate object. + + virtual int close (u_long = 0); + // Shut down. + + int svc (void); + // Thread runs here. + +private: + MT_TASK &ph_; + // Send all input to ph_. + + static void handler (int signum); + // Handle a ^C. (Do nothing). + + int put (ACE_Message_Block *, ACE_Time_Value *) { return 0; } + // Make Task happy. + + void register_thread_exit_hook (void); + // Helper function to register with the ReactorEx for thread exit. + + virtual int handle_signal (int index, siginfo_t *, ucontext_t *); + // The STDIN thread has exited. This means the user hit ^C. We can + // end the event loop. +}; + +Peer_Handler::Peer_Handler (int argc, char *argv[]) + : host_ (0), + port_ (ACE_DEFAULT_SERVER_PORT) +{ + ACE_Get_Opt get_opt (argc, argv, "h:p:"); + int c; + + while ((c = get_opt ()) != EOF) + { + switch (c) + { + case 'h': + host_ = get_opt.optarg; + break; + case 'p': + port_ = ACE_OS::atoi (get_opt.optarg); + break; + } + } + + // Auto reset event. + new_msg_event_ = ::CreateEvent (NULL, FALSE, FALSE, NULL); + ACE_Service_Config::reactorEx ()-> + register_handler (this, new_msg_event_); +} + +// This method creates the network connection to the remote peer. It +// does blocking connects and accepts depending on whether a hostname +// was specified from the command line. + +int +Peer_Handler::open (void *) +{ + if (host_ != 0) // Connector + { + ACE_INET_Addr addr (port_, host_); + ACE_SOCK_Connector connector; + + // Establish connection with server. + if (connector.connect (stream_, addr) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "connect"), -1); + + ACE_DEBUG ((LM_DEBUG, "connected.\n")); + } + else // Acceptor + { + ACE_SOCK_Acceptor acceptor; + ACE_INET_Addr local_addr (port_); + + if ((acceptor.open (local_addr) == -1) || + (acceptor.accept (this->stream_) == -1)) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "accept failed"), -1); + + ACE_DEBUG ((LM_DEBUG, "accepted.\n")); + } + + return ACE_Service_Config::proactor ()->initiate + (this, ACE_Event_Handler::READ_MASK); +} + +// One of our asynchronous writes to the remote peer has completed. +// Make sure it succeeded and then delete the message. + +int +Peer_Handler::handle_output_complete (ACE_Message_Block *msg, + long bytes_transfered) +{ + if (bytes_transfered <= 0) + ACE_DEBUG ((LM_DEBUG, "%p bytes = %d\n", "Message failed", + bytes_transfered)); + + // This was allocated by the STDIN_Handler, queued, dequeued, + // passed to the proactor, and now passed back to us. + delete msg; + return 0; // Do not reinvoke a send. +} + +// The remote peer has sent us something. If it succeeded, print +// out the message and reinitiate a read. Otherwise, fail. In both +// cases, delete the message sent. + +int +Peer_Handler::handle_input_complete (ACE_Message_Block *msg, + long bytes_transfered) +{ + if ((bytes_transfered > 0) && (msg->length () > 0)) + { + msg->rd_ptr ()[bytes_transfered] = '\0'; + // Print out the message received from the server. + ACE_DEBUG ((LM_DEBUG, "%s", msg->rd_ptr ())); + delete msg; + return 1; // Reinvokes the recv() operation! + } + + delete msg; + // If a read failed, we will assume it's because the remote peer + // went away. We will end the event loop. Since we're in the main + // thread, we don't need to do a notify. + ACE_Service_Config::end_reactorEx_event_loop (); + return -1; // Close down. +} + +// This is so the Proactor can get a message to read into. + +ACE_Message_Block * +Peer_Handler::get_message (void) +{ + // An extra byte for NUL termination. + ACE_Message_Block *message = + new ACE_Message_Block (BUFSIZ + 1); + + message->size (BUFSIZ); + return message; +} + +// This is so the Proactor can get our handle. +ACE_HANDLE +Peer_Handler::get_handle (void) const +{ + return this->stream_.get_handle (); +} + +// We've been removed from the ReactorEx. +int +Peer_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) +{ + ACE_DEBUG ((LM_DEBUG, "Peer_Handler closing down\n")); + return 0; +} + +// We've been signaled by the STDIN thread. Try to dequeue a +// message. + +int +Peer_Handler::handle_signal (int, siginfo_t *, ucontext_t *) +{ + this->try_send (); + return 0; +} + +// Try to dequeue a message. If successful, send it proactively to +// the remote peer. + +void +Peer_Handler::try_send (void) +{ + ACE_Message_Block *mb; + + ACE_Time_Value tv (ACE_Time_Value::zero); + + if (this->getq (mb, &tv) != -1) + { + if (ACE_Service_Config::proactor ()-> + initiate (this, ACE_Event_Handler::WRITE_MASK, mb) == -1) + ACE_ERROR ((LM_ERROR, "%p Write initiate.\n", "Peer_Handler")); + } +} + +// Enqueue the new mb and signal the main thread. + +int +Peer_Handler::put (ACE_Message_Block *mb, ACE_Time_Value *tv) +{ + // Enqueue the mb. + int result = this->putq (mb, tv); + + // Signal the main thread. This will remain signaled until the main + // thread wakes up. + + if (::SetEvent (new_msg_event_) == 0) + ACE_ERROR ((LM_ERROR, "Pulse Failed!\n")); + + return result; +} + +void +STDIN_Handler::handler (int signum) +{ + ACE_DEBUG ((LM_DEBUG, "signal = %S\n", signum)); +} + +STDIN_Handler::STDIN_Handler (MT_TASK &ph) + : ph_ (ph) +{ + // Register for ^C from the console. We just need to catch the + // exception so that the kernel doesn't kill our process. + // Registering this signal handler just tells the kernel that we + // know what we're doing; to leave us alone. + ACE_OS::signal (SIGINT, ACE_SignalHandler (STDIN_Handler::handler)); +}; + +// Activate object. + +int +STDIN_Handler::open (void *) +{ + if (this->activate (THR_NEW_LWP | THR_DETACHED) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), -1); + + return 0; +} + +// Shut down. + +int +STDIN_Handler::close (u_long) +{ + ACE_DEBUG ((LM_DEBUG, "(%t) thread is exiting.\n")); + return 0; +} + +// Thread runs here. + +int +STDIN_Handler::svc (void) +{ + this->register_thread_exit_hook (); + + for (;;) + { + ACE_Message_Block *mb = new ACE_Message_Block (BUFSIZ); + + // Read from stdin into mb. + int read_result = ACE_OS::read (ACE_STDIN, + mb->rd_ptr (), + mb->size ()); + + // If read succeeds, put mb to peer handler, else end the loop. + if (read_result > 0) + { + mb->wr_ptr (read_result); + this->ph_.put (mb); + } + else + break; + } + + // handle_signal will get called. + return 42; +} + +// Register an exit hook with the reactorEx. All this junk is testing +// out how ACE_Thread::self (hthread_id&) doesn't work!! + +void +STDIN_Handler::register_thread_exit_hook (void) +{ + ACE_hthread_t handle; + + // Get a real handle to our thread. + ACE_Service_Config::thr_mgr ()->thr_self (handle); + + // Register ourselves to get called back when our thread exits. + + if (ACE_Service_Config::reactorEx ()-> + register_handler (this, handle) == -1) + ACE_ERROR ((LM_ERROR, "Exit_Hook Register failed.\n")); + + // We're in another thread, so we need to notify the ReactorEx so + // that it wakes up and waits on the new set of handles. + ACE_Service_Config::reactorEx ()->notify (); +} + +// The STDIN thread has exited. This means the user hit ^C. We can +// end the event loop and delete ourself. + +int +STDIN_Handler::handle_signal (int, siginfo_t *, ucontext_t *) +{ + ACE_DEBUG ((LM_DEBUG, "STDIN thread has exited.\n")); + ACE_Service_Config::end_reactorEx_event_loop (); + return 0; +} + +int +main (int argc, char *argv[]) +{ + // Open handler for remote peer communications this will run from + // the main thread. + Peer_Handler peer_handler (argc, argv); + + if (peer_handler.open () == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "%p open failed, errno = %d.\n", + "peer_handler", errno), 0); + + // Open active object for reading from stdin. + STDIN_Handler stdin_handler (peer_handler); + + if (stdin_handler.open () == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "%p open failed, errno = %d.\n", + "stdin_handler", errno), 0); + + // Register proactor with ReactorEx so that we can demultiplex + // "waitable" events and I/O operations from a single thread. + if (ACE_Service_Config::reactorEx ()->register_handler + (ACE_Service_Config::proactor ()) != 0) + ACE_ERROR_RETURN ((LM_ERROR, "%p failed to register Proactor.\n", + argv[0]), -1); + + // Run main event demultiplexor. + ACE_Service_Config::run_reactorEx_event_loop (); + + return 42; +} diff --git a/examples/Reactor/WFMO_Reactor/test_remove_handler.cpp b/examples/Reactor/WFMO_Reactor/test_remove_handler.cpp new file mode 100644 index 00000000000..fb61519b1e9 --- /dev/null +++ b/examples/Reactor/WFMO_Reactor/test_remove_handler.cpp @@ -0,0 +1,94 @@ +// ============================================================================ +// @(#)test_remove_handler.cpp 1.1 10/18/96 + +// +// = LIBRARY +// examples +// +// = FILENAME +// test_remove_handler.cpp +// +// = DESCRIPTION +// Tests the ReactorEx's ability to handle simultaneous events. If +// you pass anything on the command-line, then each handler +// requests to be removed from the ReactorEx after each event. +// This has a funky effect on the order in which handlers are +// serviced. So, if no parameters are passed in, the handlers +// should be serviced 1 through MAXIMUM_WAIT_OBJECTS. If handlers +// to request to be removed as signals occur, they will be serviced +// 1, MAX, MAX-1, ..., 2. This is because of a ReactorEx +// bookkeeping optimization. +// +// = AUTHOR +// Tim Harrison +// +// ============================================================================ + +#include "ace/ReactorEx.h" +#include "ace/Service_Config.h" +#include "ace/Synch.h" + +class Event_Handler : public ACE_Event_Handler +// = TITLE +// Generic Event Handler. +// +// = DESCRIPTION +// +// Creates event. Registers with ReactorEx. Signals event. If +// created with -close_down- it returns -1 from handle signal. +{ +public: + Event_Handler (int event_number, + int close_down) + : event_number_ (event_number), + close_down_ (close_down) + { + ACE_Service_Config::reactorEx ()->register_handler (this, + this->event_.handle ()); + this->event_.signal (); + } + + virtual int handle_signal (int index, siginfo_t *, ucontext_t *) + { + ACE_DEBUG ((LM_DEBUG, "event %d occured.\n", event_number_)); + + if (this->close_down_) + return -1; + else + return 0; + } + + virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask) + { + // ACE_DEBUG ((LM_DEBUG, "event handler %d closed.\n", event_number_)); + delete this; + return 0; + } + + virtual ACE_HANDLE get_handle (void) const + { + return event_.handle (); + } + +private: + int event_number_; + // Our event number. + + int close_down_; + // Shall we close down or not. + + ACE_Event event_; + // Signaled to shut down the handler. +}; + +int +main (int argc, char *argv[]) +{ + int close_down = arg > 1 ? 1 : 0; + + for (int i = 0; i < ACE_ReactorEx::MAX_SIZE; i++) + new Event_Handler (i, close_down); + + ACE_Service_Config::reactorEx ()->handle_events (); + return 42; +} diff --git a/examples/Service_Configurator/IPC-tests/Makefile b/examples/Service_Configurator/IPC-tests/Makefile new file mode 100644 index 00000000000..a90224788d8 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/Makefile @@ -0,0 +1,24 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the IPC tests +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +INFO = + +DIRS = client \ + server + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nolocal.GNU diff --git a/examples/Service_Configurator/IPC-tests/README b/examples/Service_Configurator/IPC-tests/README new file mode 100644 index 00000000000..4af5114358a --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/README @@ -0,0 +1,112 @@ +This file describes how to invoke the Reactor client/server tests in +the $WRAPPER_ROOT/tests/Reactor/{client,server} directories. + +These tests exercise all of the IPC_SAP communication mechanisms, the +Reactor event demultiplexor, and the Service Configurator dynamic +service configuration framework. To gain a deeper understanding of +what is going on, you should read the IPC_SAP.ps, reactor-[1-3].ps, +and service_configurator.ps papers available for anonymous ftp from +ics.uci.edu in the ftp/gnu/C++_wrappers_doc.tar.Za[a-c] files. + +The key to running the Reactor client/server tests is to understand +the purpose of the svc.conf file located in the +$WRAPPER_ROOT/tests/Reactor/server directory. This file contains a +list of services that may be dynamically configured into a the address +space of a network daemon process. If you look at the example +svc.conf file included in the Reactor tests you'll see that most of +the entries are commented out (the comment symbol is the '#', which is +an "ignore until end-of-line comment" with the same semantics as the +UNIX C and Bourne shells). Before reading any further, take a look at +this svc.conf file with your favorite editor or file browser. + +There are several types of entries in this file. The two most +important are the lines beginning with the keywords "static" and +"dynamic". For example, the first non-commented line says: + +static Svc_Manager "-d -p 3911" + +When this line is parsed at startup time by the Service Configurator +object in the ./server_test executable, it causes the pre-configured +Svc_Manager object to be initialized with an "argv" argument of "-d -p +3911." This results in TCP port 3911 being created to listen +connection requests from clients. To see how this works do the +following: + +1. Comment out all the other lines except + +static Svc_Manager "-d -p 3911" + + in the svc.conf file + +2. Start up the ./server_test executable in one window, as follows: + + % ./server_test -d + +3. Make another window on the *same* host and cd to the ../client + directory + +4. Run the ./remote_service_directory_test program as follows: + + % ./remote_service_directory_test -p 3911 -h localhost + +If everything has been compiled and initialized correctly, you should +get the following message: + + Svc_Manager 3911/tcp # lists all services in the daemon + +This message is telling you that the Svc_Manager is currently the only +service that is active within the ./server_test program. To configure +and activate another service dynamically, perform the following steps: + +1. *Without* shutting down the ./server_test program, edit the svc.conf + file. Comment out the Svc_Manager line by adding a '#' at the front, i.e.: + +# static Svc_Manager "-d -p 3911" + + and then uncomment the second line: + +dynamic Remote_Brdcast Service_Object * .obj/Handle_Broadcast.so:remote_broadcast "-p 10001" + +2. Send the SIGHUP signal to the process running the ./server_test program + (use "ps -gux" on SunOS 4.x or "ps -elf" on SunOS 5.x to find the + correct process id). This will cause the ./server_test program to + reconfigure itself based on the new contents of the svc.conf file. + After reconfiguration, you'll now have a second active service in + the address space of the ./server_test daemon. To see this, rerun + the remote_service_directory_test command, e.g.: + + % ./remote_service_directory_test -p 3911 -h localhost + + You should now see the following output: + + Svc_Manager 3911/tcp # lists all services in the daemon + Remote_Brdcast 10001/udp # tests broadcasting + + which indicates that the remote broadcast service is now active. + +3. To test the remote broadcast service, run the following program + in the ../client directory: + + % ./broadcast_client_test -p 10001 + + This should cause the window running the ./server_test to + display the following output: + + received broadcast datagram from host spare.ics.uci.edu + ---------------------------------------- + testing socket broadcast service + ---------------------------------------- + +If you want to run other tests, using other configurations, simply +uncomment the appropriate lines in the svc.conf file and experiment +with the corresponding test drivers in the ../client directory. All +the source code is available so once you get the hang of what is +happening, you might want to take a look at how it is all implemented. +I think you'll be surprised at how much of the ACE framework code is +reused for each different service. Moreover, writing a new service is +often simply a matter of copying an existing file and filling in the +behavior of some of the methods (e.g., the handle_input() method and +the init() method). + +The service_configurator.ps paper and the ACE.ps paper describe the +details of the Service Configurator framework. diff --git a/examples/Service_Configurator/IPC-tests/client/Makefile b/examples/Service_Configurator/IPC-tests/client/Makefile new file mode 100644 index 00000000000..d6fbca0eeac --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/client/Makefile @@ -0,0 +1,306 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the client-side of the primary Reactor tests +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = local_dgram_client_test \ + local_stream_client_test \ + local_pipe_client_test \ + remote_stream_client_test \ + remote_thr_stream_client_test \ + remote_dgram_client_test \ + local_fifo_client_test \ + broadcast_client_test \ + local_spipe_client_test \ + remote_service_directory_test + +LSRC = $(addsuffix .cpp,$(BIN)) + +LDLIBS = + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +INSTALL = + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/local_dgram_client_test.o .shobj/local_dgram_client_test.so: local_dgram_client_test.cpp \ + $(WRAPPER_ROOT)/ace/LSOCK_CODgram.h \ + $(WRAPPER_ROOT)/ace/LSOCK.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/LSOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_CODgram.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/SOCK_CODgram.i \ + $(WRAPPER_ROOT)/ace/LSOCK_CODgram.i \ + $(WRAPPER_ROOT)/ace/LSOCK_Dgram.h \ + $(WRAPPER_ROOT)/ace/SOCK_Dgram.h \ + $(WRAPPER_ROOT)/ace/SOCK_Dgram.i \ + $(WRAPPER_ROOT)/ace/LSOCK_Dgram.i \ + $(WRAPPER_ROOT)/ace/UNIX_Addr.h \ + $(WRAPPER_ROOT)/ace/Get_Opt.h +.obj/local_stream_client_test.o .shobj/local_stream_client_test.so: local_stream_client_test.cpp \ + $(WRAPPER_ROOT)/ace/LSOCK_Connector.h \ + $(WRAPPER_ROOT)/ace/SOCK_Connector.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/SOCK_Connector.i \ + $(WRAPPER_ROOT)/ace/LSOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/LSOCK.h \ + $(WRAPPER_ROOT)/ace/LSOCK.i \ + $(WRAPPER_ROOT)/ace/LSOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/UNIX_Addr.h \ + $(WRAPPER_ROOT)/ace/LSOCK_Connector.i \ + $(WRAPPER_ROOT)/ace/Get_Opt.h +.obj/local_pipe_client_test.o .shobj/local_pipe_client_test.so: local_pipe_client_test.cpp \ + $(WRAPPER_ROOT)/ace/LSOCK_Connector.h \ + $(WRAPPER_ROOT)/ace/SOCK_Connector.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/SOCK_Connector.i \ + $(WRAPPER_ROOT)/ace/LSOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/LSOCK.h \ + $(WRAPPER_ROOT)/ace/LSOCK.i \ + $(WRAPPER_ROOT)/ace/LSOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/UNIX_Addr.h \ + $(WRAPPER_ROOT)/ace/LSOCK_Connector.i \ + $(WRAPPER_ROOT)/ace/Get_Opt.h +.obj/remote_stream_client_test.o .shobj/remote_stream_client_test.so: remote_stream_client_test.cpp \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/SOCK_Connector.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/SOCK_Connector.i \ + $(WRAPPER_ROOT)/ace/SOCK_CODgram.h \ + $(WRAPPER_ROOT)/ace/SOCK_CODgram.i \ + $(WRAPPER_ROOT)/ace/Get_Opt.h +.obj/remote_thr_stream_client_test.o .shobj/remote_thr_stream_client_test.so: remote_thr_stream_client_test.cpp \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/TLI_Connector.h \ + $(WRAPPER_ROOT)/ace/TLI_Stream.h \ + $(WRAPPER_ROOT)/ace/TLI.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/TLI.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/TLI_Stream.i \ + $(WRAPPER_ROOT)/ace/TLI_Connector.i \ + $(WRAPPER_ROOT)/ace/Get_Opt.h +.obj/remote_dgram_client_test.o .shobj/remote_dgram_client_test.so: remote_dgram_client_test.cpp \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/SOCK_Dgram.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_Dgram.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/Get_Opt.h +.obj/local_fifo_client_test.o .shobj/local_fifo_client_test.so: local_fifo_client_test.cpp \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/FIFO_Send_Msg.h \ + $(WRAPPER_ROOT)/ace/FIFO_Send.h \ + $(WRAPPER_ROOT)/ace/FIFO.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/FIFO_Send.i \ + $(WRAPPER_ROOT)/ace/FIFO_Send_Msg.i \ + $(WRAPPER_ROOT)/ace/Get_Opt.h +.obj/broadcast_client_test.o .shobj/broadcast_client_test.so: broadcast_client_test.cpp \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Dgram_Bcast.h \ + $(WRAPPER_ROOT)/ace/SOCK_Dgram.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_Dgram.i \ + $(WRAPPER_ROOT)/ace/SOCK_Dgram_Bcast.i \ + $(WRAPPER_ROOT)/ace/Get_Opt.h +.obj/local_spipe_client_test.o .shobj/local_spipe_client_test.so: local_spipe_client_test.cpp \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Connector.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/SPIPE.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/SPIPE.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Connector.i \ + $(WRAPPER_ROOT)/ace/Get_Opt.h +.obj/remote_service_directory_test.o .shobj/remote_service_directory_test.so: remote_service_directory_test.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/SOCK_Connector.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/SOCK_Connector.i \ + $(WRAPPER_ROOT)/ace/Get_Opt.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/Service_Configurator/IPC-tests/client/broadcast_client_test.cpp b/examples/Service_Configurator/IPC-tests/client/broadcast_client_test.cpp new file mode 100644 index 00000000000..57d417441f7 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/client/broadcast_client_test.cpp @@ -0,0 +1,56 @@ +/* Tests out the broadcast service of the +// @(#)broadcast_client_test.cpp 1.1 10/18/96 + + Internet domain IPC-SAP dgram abstraction. */ + +#include "ace/INET_Addr.h" +#include "ace/SOCK_Dgram_Bcast.h" +#include "ace/Log_Msg.h" +#include "ace/Get_Opt.h" + +/* Name of the program. */ +static char *program_name; + +/* Port number to use. */ +static unsigned short broadcast_port_number = ACE_DEFAULT_BROADCAST_PORT; + +static void +print_usage_and_die (void) +{ + ACE_OS::fprintf (stderr, "usage: %s [-p broadcast portnum]\n", + program_name); + ACE_OS::exit (1); +} + +void +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opt (argc, argv, "p:"); + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'p': + broadcast_port_number = ACE_OS::atoi (get_opt.optarg); + break; + default: + print_usage_and_die (); + break; + } +} + +int +main (int argc, char *argv[]) +{ + program_name = argv[0]; + parse_args (argc, argv); + + ACE_SOCK_Dgram_Bcast sd (ACE_Addr::sap_any); + + static char buf[] = "testing socket broadcast service"; + + if (sd.send (buf, strlen (buf), broadcast_port_number) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "can't send broadcast"), -1); + + return 0; +} diff --git a/examples/Service_Configurator/IPC-tests/client/local_data b/examples/Service_Configurator/IPC-tests/client/local_data new file mode 100644 index 00000000000..1faba1b8091 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/client/local_data @@ -0,0 +1,22 @@ +locallocallocallocallocallocallocallocal +locallocallocallocallocallocallocallocal +locallocallocallocallocallocallocallocal +locallocallocallocallocallocallocallocal +locallocallocallocallocallocallocallocal +locallocallocallocallocallocallocallocal +locallocallocallocallocallocallocallocal +locallocallocallocallocallocallocallocal +locallocallocallocallocallocallocallocal +locallocallocallocallocallocallocallocal +locallocallocallocallocallocallocallocal +locallocallocallocallocallocallocallocal +locallocallocallocallocallocallocallocal +locallocallocallocallocallocallocallocal +locallocallocallocallocallocallocallocal +locallocallocallocallocallocallocallocal +locallocallocallocallocallocallocallocal +locallocallocallocallocallocallocallocal +locallocallocallocallocallocallocallocal +locallocallocallocallocallocallocallocal +locallocallocallocallocallocallocallocal +locallocallocallocallocallocallocallocal diff --git a/examples/Service_Configurator/IPC-tests/client/local_dgram_client_test.cpp b/examples/Service_Configurator/IPC-tests/client/local_dgram_client_test.cpp new file mode 100644 index 00000000000..249bdfa83d5 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/client/local_dgram_client_test.cpp @@ -0,0 +1,94 @@ +/* Tests out the UNIX domain IPC-SAP abstraction. */ +// @(#)local_dgram_client_test.cpp 1.1 10/18/96 + + +#include "ace/LSOCK_CODgram.h" +#include "ace/LSOCK_Dgram.h" +#include "ace/UNIX_Addr.h" +#include "ace/Log_Msg.h" +#include "ace/Get_Opt.h" + +#if defined (ACE_HAS_MSG) && !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) +/* Name of the program. */ +static char *program_name; + +/* Number of seconds to sleep. */ +static int seconds = 3; + +/* Name of rendezvous point. */ +static char *rendezvous_codgram = "/tmp/foo_codgram"; +static char *rendezvous_dgram = "/tmp/foo_dgram"; + +/* Name of file to send. */ +static char *file_name = "local_data"; + +static void print_usage_and_die (void) +{ + ACE_ERROR ((LM_ERROR, "usage: %s [-r rendezvous_dgram] [-c rendezvous_codgram] [-f file] [-n seconds]\n%a", + program_name, -1)); +} + +void +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opt (argc, argv, "c:f:n:r:"); + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'f': + file_name = get_opt.optarg; + break; + case 'n': + seconds = atoi (get_opt.optarg); + break; + case 'r': + rendezvous_dgram = get_opt.optarg; + break; + case 'c': + rendezvous_codgram = get_opt.optarg; + break; + default: + print_usage_and_die (); + break; + } +} + +int +main (int argc, char *argv[]) +{ + program_name = argv[0]; + + parse_args (argc, argv); + + ACE_LSOCK_Dgram sd (ACE_Addr::sap_any); + ACE_LSOCK_CODgram sc; + int fd; + + if (sc.open (ACE_UNIX_Addr (rendezvous_codgram), ACE_Addr::sap_any) < 0) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); + + if ((fd = ACE_OS::open (file_name, O_RDONLY)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); + + /* Send the open file descriptor to the server! */ + + if (sc.send_handle (fd) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send"), -1); + + char *name = ACE_OS::cuserid (0); + + if (sd.send (name, strlen (name) + 1, ACE_UNIX_Addr (rendezvous_dgram)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send"), -1); + + if (ACE_OS::close (fd) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), -1); + + return 0; +} +#else +int main (void) +{ + ACE_ERROR_RETURN ((LM_ERROR, "your platform must support sendmsg/recvmsg to run this test\n"), -1); +} +#endif /* ACE_HAS_MSG */ diff --git a/examples/Service_Configurator/IPC-tests/client/local_fifo_client_test.cpp b/examples/Service_Configurator/IPC-tests/client/local_fifo_client_test.cpp new file mode 100644 index 00000000000..f136ce465bf --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/client/local_fifo_client_test.cpp @@ -0,0 +1,85 @@ +/* Send a file through ACE_FIFO communication channel by +// @(#)local_fifo_client_test.cpp 1.1 10/18/96 + + break it (the file) into pieces. */ + +#include "ace/Mem_Map.h" +#include "ace/FIFO_Send_Msg.h" +#include "ace/Log_Msg.h" +#include "ace/Get_Opt.h" + +static const BUF_LEN = 256; + +// Name of the program. +static char *program_name; + +// debug state on or off +static int debug = 0; + +char *rendezvous_fifo = "/tmp/foo_fifo"; + +/* Name of file to send. */ +static char *file_name = "./local_data"; + +static void +print_usage_and_die (void) +{ + ACE_ERROR ((LM_ERROR, "usage: %s [-d] [-f rendezvous_fifo]\n%a", + program_name, -1)); +} + +static void +parse_arguments (int argc, char *argv[]) +{ + int tracing = 1; + program_name = argv[0]; + + ACE_Get_Opt get_opt (argc, argv, "df:"); + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'd': + debug = 1; + break; + case 'f': + rendezvous_fifo = get_opt.optarg; + break; + default: + print_usage_and_die (); + break; + } + + if (debug) + ACE_DEBUG ((LM_DEBUG, + "rendezvous_fifo = %s\n" + "trace = %s\n", + rendezvous_fifo, tracing ? "on" : "off")); +} + +int +main(int argc, char *argv[]) +{ + parse_arguments (argc, argv); + + ACE_FIFO_Send_Msg fifo; + + if (fifo.open ((const char *) rendezvous_fifo, O_WRONLY, 0666) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "Cannot open %s for requesting a new communication channel" + "in local_fifo_client_test\n", rendezvous_fifo), -1); + + + void *cp; + ACE_Mem_Map mmap (file_name); + + if (mmap (cp) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "mmap"), -1); + + /* Next, send the file's contents. */ + + ACE_Str_Buf msg (cp, int (mmap.size ())); + + if (fifo.send (msg) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send"), -1); + return 0; +} diff --git a/examples/Service_Configurator/IPC-tests/client/local_pipe_client_test.cpp b/examples/Service_Configurator/IPC-tests/client/local_pipe_client_test.cpp new file mode 100644 index 00000000000..cb09bd0eade --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/client/local_pipe_client_test.cpp @@ -0,0 +1,122 @@ +// Another test of UNIX domain IPC-SAP abstraction. This one opens 2 +// @(#)local_pipe_client_test.cpp 1.1 10/18/96 + +// pipes and then ships certain ends over to the server to act as a +// filter! + +#include "ace/LSOCK_Connector.h" +#include "ace/UNIX_Addr.h" +#include "ace/Log_Msg.h" +#include "ace/Get_Opt.h" + +#if defined (ACE_HAS_MSG) && !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) +/* Name of the program. */ +static char *program_name; + +/* Name of rendezvous point. */ +static char *rendezvous = "/tmp/foo_pipe"; + +/* Name of file to send. */ +static char *file_name = "local_data"; + +static void +print_usage_and_die (void) +{ + ACE_ERROR ((LM_ERROR, "usage: %s [-r rendezvous] [-f file]\n%a", + program_name, -1)); +} + +void +parse_args (int argc, char *argv[]) +{ + program_name = argv[0]; + + ACE_Get_Opt get_opt (argc, argv, "f:r:"); + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'f': + file_name = get_opt.optarg; + break; + case 'r': + rendezvous = get_opt.optarg; + break; + default: + print_usage_and_die (); + break; + } +} + +int +do_client_processing (ACE_LSOCK_Stream &sc) +{ + int fd_read[2]; + int fd_write[2]; + char buf[BUFSIZ]; + int n; + int fd1; + + if (ACE_OS::pipe (fd_read) == -1 || ACE_OS::pipe (fd_write) == -1) + return -1; + + if (sc.send_handle (fd_write[0]) == -1 || sc.send_handle (fd_read[1]) == -1) + return -1; + + /* Close off the ends we aren't interested in. */ + + if (ACE_OS::close (fd_read[1]) || ACE_OS::close (fd_write[0]) == -1) + return -1; + + /* Do a silly dup just for fun... */ + + if ((fd1 = ACE_OS::open (file_name, O_RDONLY)) == -1) + return -1; + + while ((n = ACE_OS::read (fd1, buf, sizeof buf)) > 0) + { + if (ACE_OS::write (fd_write[1], buf, n) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "write"), -1); + if ((n = ACE_OS::read (fd_read[0], buf, sizeof buf)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "read"), -1); + if (ACE_OS::write (ACE_STDOUT, buf, n) == -1) + return -1; + } + + if (ACE_OS::close (fd_read[0]) == -1 + || ACE_OS::close (fd_write[1]) == -1 + || ACE_OS::close (fd1) == -1) + ACE_OS::exit (1); + + return 0; +} + +int +main (int argc, char *argv[]) +{ + parse_args (argc, argv); + + ACE_LSOCK_Stream sc; + ACE_LSOCK_Connector con; + + if (con.connect (sc, ACE_UNIX_Addr (rendezvous)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "connect"), -1); + + if (do_client_processing (sc) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "do_client_processing"), -1); + +#if defined (SunOS4) + ACE_OS::sleep (1); +#endif /* SunOS4 */ + + if (sc.close () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), -1); + + return 0; +} +#else +int main (void) +{ + ACE_ERROR_RETURN ((LM_ERROR, "your platform must support sendmsg/recvmsg to run this test\n"), -1); +} +#endif /* ACE_HAS_MSG */ diff --git a/examples/Service_Configurator/IPC-tests/client/local_spipe_client_test.cpp b/examples/Service_Configurator/IPC-tests/client/local_spipe_client_test.cpp new file mode 100644 index 00000000000..0dbe3abbed2 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/client/local_spipe_client_test.cpp @@ -0,0 +1,88 @@ +/* Send a file through ACE_SPIPE communication channel by +// @(#)local_spipe_client_test.cpp 1.1 10/18/96 + + break it (the file) into pieces. */ + +#include "ace/Mem_Map.h" +#include "ace/SPIPE_Connector.h" +#include "ace/Log_Msg.h" +#include "ace/Get_Opt.h" + +#if defined (ACE_HAS_STREAM_PIPES) + +static char *program_name; + +// debug state on or off +static int debug = 0; + +char *rendezvous_spipe = "/tmp/foo_spipe"; + +/* Name of file to send. */ +static char *file_name = "./local_data"; + +static void +print_usage_and_die (void) +{ + ACE_ERROR ((LM_ERROR, "usage: %s [-d] [-r rendezvous_spipe]\n%a", + program_name, -1)); +} + +static void +parse_arguments (int argc, char *argv[]) +{ + program_name = argv[0]; + ACE_Get_Opt get_opt (argc, argv, "dr:"); + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'd': + debug = 1; + break; + case 'r': + rendezvous_spipe = get_opt.optarg; + break; + default: + print_usage_and_die (); + break; + } + if (debug) + ACE_DEBUG ((LM_DEBUG, "rendezvous_spipe = %s\n", + rendezvous_spipe)); +} + +int +main(int argc, char *argv[]) +{ + parse_arguments (argc, argv); + + ACE_SPIPE_Stream spipe; + ACE_SPIPE_Connector con; + + if (con.connect (spipe, ACE_SPIPE_Addr (rendezvous_spipe)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot open %s for requesting a new communication channel" + " in local_spipe_client_test.\n", rendezvous_spipe), -1); + + ACE_Mem_Map mmap (file_name); + void *cp; + + if (mmap (cp) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "mmap"), -1); + + /* Next, send the file's contents. */ + + ACE_Str_Buf msg (cp, int (mmap.size ())); + + if (spipe.send ((ACE_Str_Buf *) 0, &msg) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send"), -1); + return 0; +} +#else +#include <stdio.h> +int +main (void) +{ + ACE_ERROR_RETURN ((LM_ERROR, "This feature is not supported\n"), -1); +} +#endif /* ACE_HAS_STREAM_PIPES */ diff --git a/examples/Service_Configurator/IPC-tests/client/local_stream_client_test.cpp b/examples/Service_Configurator/IPC-tests/client/local_stream_client_test.cpp new file mode 100644 index 00000000000..bf168d0056e --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/client/local_stream_client_test.cpp @@ -0,0 +1,85 @@ +/* Tests out the UNIX domain IPC-SAP abstraction. */ +// @(#)local_stream_client_test.cpp 1.1 10/18/96 + +#include "ace/LSOCK_Connector.h" +#include "ace/UNIX_Addr.h" +#include "ace/Log_Msg.h" +#include "ace/Get_Opt.h" + +#if defined (ACE_HAS_MSG) && !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) +/* Name of the program. */ +static char *program_name; + +/* Name of rendezvous point. */ +static char *rendezvous = "/tmp/foo_stream"; + +/* Name of file to send. */ +static char *file_name = "local_data"; + +static void +print_usage_and_die (void) +{ + ACE_ERROR ((LM_ERROR, "usage: %s [-r rendezvous] [-f file]%a\n", + program_name, -1)); +} + +void +parse_args (int argc, char *argv[]) +{ + program_name = argv[0]; + ACE_Get_Opt get_opt (argc, argv, "f:r:"); + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'f': + file_name = get_opt.optarg; + break; + case 'r': + rendezvous = get_opt.optarg; + break; + default: + print_usage_and_die (); + break; + } +} + +int +main (int argc, char *argv[]) +{ + parse_args (argc, argv); + + int fd; + char buf[BUFSIZ]; + int n; + + ACE_LSOCK_Stream sc; + ACE_LSOCK_Connector con; + + if (con.connect (sc, ACE_UNIX_Addr (rendezvous)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "connect"), -1); + + if ((fd = ACE_OS::open (file_name, O_RDONLY)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); + + /* Send the open file descriptor to the server! */ + + if (sc.send_handle (fd) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send_handle"), -1); + + if ((n = sc.recv_n (buf, sizeof buf)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "recv"), -1); + else + ACE_OS::write (ACE_STDOUT, buf, n); + + if (ACE_OS::close (fd) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), -1); + + return 0; +} +#else +int main (void) +{ + ACE_ERROR_RETURN ((LM_ERROR, "your platform must support sendmsg/recvmsg to run this test\n"), -1); +} +#endif /* ACE_HAS_MSG */ diff --git a/examples/Service_Configurator/IPC-tests/client/remote_data b/examples/Service_Configurator/IPC-tests/client/remote_data new file mode 100644 index 00000000000..ae7e1fbb88e --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/client/remote_data @@ -0,0 +1,22 @@ +remoteremoteremoteremoteremoteremoteremoteremote +remoteremoteremoteremoteremoteremoteremoteremote +remoteremoteremoteremoteremoteremoteremoteremote +remoteremoteremoteremoteremoteremoteremoteremote +remoteremoteremoteremoteremoteremoteremoteremote +remoteremoteremoteremoteremoteremoteremoteremote +remoteremoteremoteremoteremoteremoteremoteremote +remoteremoteremoteremoteremoteremoteremoteremote +remoteremoteremoteremoteremoteremoteremoteremote +remoteremoteremoteremoteremoteremoteremoteremote +remoteremoteremoteremoteremoteremoteremoteremote +remoteremoteremoteremoteremoteremoteremoteremote +remoteremoteremoteremoteremoteremoteremoteremote +remoteremoteremoteremoteremoteremoteremoteremote +remoteremoteremoteremoteremoteremoteremoteremote +remoteremoteremoteremoteremoteremoteremoteremote +remoteremoteremoteremoteremoteremoteremoteremote +remoteremoteremoteremoteremoteremoteremoteremote +remoteremoteremoteremoteremoteremoteremoteremote +remoteremoteremoteremoteremoteremoteremoteremote +remoteremoteremoteremoteremoteremoteremoteremote +remoteremoteremoteremoteremoteremoteremoteremote diff --git a/examples/Service_Configurator/IPC-tests/client/remote_data1 b/examples/Service_Configurator/IPC-tests/client/remote_data1 new file mode 100644 index 00000000000..6faaee46729 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/client/remote_data1 @@ -0,0 +1,22 @@ +remote1remote1remote1remote1remote1remote1remote1remote1 +remote1remote1remote1remote1remote1remote1remote1remote1 +remote1remote1remote1remote1remote1remote1remote1remote1 +remote1remote1remote1remote1remote1remote1remote1remote1 +remote1remote1remote1remote1remote1remote1remote1remote1 +remote1remote1remote1remote1remote1remote1remote1remote1 +remote1remote1remote1remote1remote1remote1remote1remote1 +remote1remote1remote1remote1remote1remote1remote1remote1 +remote1remote1remote1remote1remote1remote1remote1remote1 +remote1remote1remote1remote1remote1remote1remote1remote1 +remote1remote1remote1remote1remote1remote1remote1remote1 +remote1remote1remote1remote1remote1remote1remote1remote1 +remote1remote1remote1remote1remote1remote1remote1remote1 +remote1remote1remote1remote1remote1remote1remote1remote1 +remote1remote1remote1remote1remote1remote1remote1remote1 +remote1remote1remote1remote1remote1remote1remote1remote1 +remote1remote1remote1remote1remote1remote1remote1remote1 +remote1remote1remote1remote1remote1remote1remote1remote1 +remote1remote1remote1remote1remote1remote1remote1remote1 +remote1remote1remote1remote1remote1remote1remote1remote1 +remote1remote1remote1remote1remote1remote1remote1remote1 +remote1remote1remote1remote1remote1remote1remote1remote1 diff --git a/examples/Service_Configurator/IPC-tests/client/remote_data2 b/examples/Service_Configurator/IPC-tests/client/remote_data2 new file mode 100644 index 00000000000..ae6bf12d49f --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/client/remote_data2 @@ -0,0 +1,22 @@ +remote2remote2remote2remote2remote2remote2remote2remote2 +remote2remote2remote2remote2remote2remote2remote2remote2 +remote2remote2remote2remote2remote2remote2remote2remote2 +remote2remote2remote2remote2remote2remote2remote2remote2 +remote2remote2remote2remote2remote2remote2remote2remote2 +remote2remote2remote2remote2remote2remote2remote2remote2 +remote2remote2remote2remote2remote2remote2remote2remote2 +remote2remote2remote2remote2remote2remote2remote2remote2 +remote2remote2remote2remote2remote2remote2remote2remote2 +remote2remote2remote2remote2remote2remote2remote2remote2 +remote2remote2remote2remote2remote2remote2remote2remote2 +remote2remote2remote2remote2remote2remote2remote2remote2 +remote2remote2remote2remote2remote2remote2remote2remote2 +remote2remote2remote2remote2remote2remote2remote2remote2 +remote2remote2remote2remote2remote2remote2remote2remote2 +remote2remote2remote2remote2remote2remote2remote2remote2 +remote2remote2remote2remote2remote2remote2remote2remote2 +remote2remote2remote2remote2remote2remote2remote2remote2 +remote2remote2remote2remote2remote2remote2remote2remote2 +remote2remote2remote2remote2remote2remote2remote2remote2 +remote2remote2remote2remote2remote2remote2remote2remote2 +remote2remote2remote2remote2remote2remote2remote2remote2 diff --git a/examples/Service_Configurator/IPC-tests/client/remote_data3 b/examples/Service_Configurator/IPC-tests/client/remote_data3 new file mode 100644 index 00000000000..7f2ec1aa81b --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/client/remote_data3 @@ -0,0 +1,22 @@ +remote3remote3remote3remote3remote3remote3remote3remote3 +remote3remote3remote3remote3remote3remote3remote3remote3 +remote3remote3remote3remote3remote3remote3remote3remote3 +remote3remote3remote3remote3remote3remote3remote3remote3 +remote3remote3remote3remote3remote3remote3remote3remote3 +remote3remote3remote3remote3remote3remote3remote3remote3 +remote3remote3remote3remote3remote3remote3remote3remote3 +remote3remote3remote3remote3remote3remote3remote3remote3 +remote3remote3remote3remote3remote3remote3remote3remote3 +remote3remote3remote3remote3remote3remote3remote3remote3 +remote3remote3remote3remote3remote3remote3remote3remote3 +remote3remote3remote3remote3remote3remote3remote3remote3 +remote3remote3remote3remote3remote3remote3remote3remote3 +remote3remote3remote3remote3remote3remote3remote3remote3 +remote3remote3remote3remote3remote3remote3remote3remote3 +remote3remote3remote3remote3remote3remote3remote3remote3 +remote3remote3remote3remote3remote3remote3remote3remote3 +remote3remote3remote3remote3remote3remote3remote3remote3 +remote3remote3remote3remote3remote3remote3remote3remote3 +remote3remote3remote3remote3remote3remote3remote3remote3 +remote3remote3remote3remote3remote3remote3remote3remote3 +remote3remote3remote3remote3remote3remote3remote3remote3 diff --git a/examples/Service_Configurator/IPC-tests/client/remote_data4 b/examples/Service_Configurator/IPC-tests/client/remote_data4 new file mode 100644 index 00000000000..6c5a9633d56 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/client/remote_data4 @@ -0,0 +1,22 @@ +remote4remote4remote4remote4remote4remote4remote4remote4 +remote4remote4remote4remote4remote4remote4remote4remote4 +remote4remote4remote4remote4remote4remote4remote4remote4 +remote4remote4remote4remote4remote4remote4remote4remote4 +remote4remote4remote4remote4remote4remote4remote4remote4 +remote4remote4remote4remote4remote4remote4remote4remote4 +remote4remote4remote4remote4remote4remote4remote4remote4 +remote4remote4remote4remote4remote4remote4remote4remote4 +remote4remote4remote4remote4remote4remote4remote4remote4 +remote4remote4remote4remote4remote4remote4remote4remote4 +remote4remote4remote4remote4remote4remote4remote4remote4 +remote4remote4remote4remote4remote4remote4remote4remote4 +remote4remote4remote4remote4remote4remote4remote4remote4 +remote4remote4remote4remote4remote4remote4remote4remote4 +remote4remote4remote4remote4remote4remote4remote4remote4 +remote4remote4remote4remote4remote4remote4remote4remote4 +remote4remote4remote4remote4remote4remote4remote4remote4 +remote4remote4remote4remote4remote4remote4remote4remote4 +remote4remote4remote4remote4remote4remote4remote4remote4 +remote4remote4remote4remote4remote4remote4remote4remote4 +remote4remote4remote4remote4remote4remote4remote4remote4 +remote4remote4remote4remote4remote4remote4remote4remote4 diff --git a/examples/Service_Configurator/IPC-tests/client/remote_dgram_client_test.cpp b/examples/Service_Configurator/IPC-tests/client/remote_dgram_client_test.cpp new file mode 100644 index 00000000000..54cde3aef67 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/client/remote_dgram_client_test.cpp @@ -0,0 +1,78 @@ +/* Tests out the Internet domain IPC-SAP dgram abstraction. */ +// @(#)remote_dgram_client_test.cpp 1.1 10/18/96 + + +#include "ace/Mem_Map.h" +#include "ace/SOCK_Dgram.h" +#include "ace/Log_Msg.h" +#include "ace/INET_Addr.h" +#include "ace/Get_Opt.h" + +/* Name of the program. */ +static char *program_name; + +/* Port number to use. */ +static unsigned short port_number = ACE_DEFAULT_SERVER_PORT; + +/* Name of remote host. */ +static char *host_name = ACE_DEFAULT_SERVER_HOST; + +/* Name of file to send. */ +static char *file_name = "./remote_data"; + +static void print_usage_and_die (void) +{ + ACE_ERROR ((LM_ERROR, "usage: %s [-p portnum] [-h host_name] [-f file]\n%a", + program_name, -1)); +} + +void +parse_args (int argc, char *argv[]) +{ + program_name = argv[0]; + + ACE_Get_Opt get_opt (argc, argv, "f:h:p:"); + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'f': + file_name = get_opt.optarg; + break; + case 'h': + host_name = get_opt.optarg; + break; + case 'p': + port_number = ACE_OS::atoi (get_opt.optarg); + break; + default: + print_usage_and_die (); + break; + } +} + +int +main (int argc, char *argv[]) +{ + parse_args (argc, argv); + + ACE_SOCK_Dgram sd (ACE_Addr::sap_any); + void *cp; + ACE_INET_Addr sa (port_number, host_name); + + ACE_Mem_Map mmap (file_name); + + if (mmap (cp) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "mmap"), -1); + + /* Next, send the file's contents. */ + + int cc = sd.send (cp, mmap.size (), sa); + + if (cc == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send"), -1); + else if (cc != mmap.size()) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", + "Not all the contents of mmap file are sent."), -1); + return 0; +} diff --git a/examples/Service_Configurator/IPC-tests/client/remote_service_directory_test.cpp b/examples/Service_Configurator/IPC-tests/client/remote_service_directory_test.cpp new file mode 100644 index 00000000000..365f6c7efb0 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/client/remote_service_directory_test.cpp @@ -0,0 +1,80 @@ +/* Test program for the INET IPC-SAPs... */ +// @(#)remote_service_directory_test.cpp 1.1 10/18/96 + + +#include "ace/Log_Msg.h" +#include "ace/SOCK_Connector.h" +#include "ace/INET_Addr.h" +#include "ace/Get_Opt.h" + +/* Port number to use. */ +static unsigned short port_number = ACE_DEFAULT_SERVICE_PORT; + +/* Name of remote host. */ +static char *host_name = ACE_DEFAULT_SERVER_HOST; + +/* Trigger a remote reconfiguration */ +static int remote_reconfigure = 0; + +static void +print_usage_and_die (void) +{ + ACE_ERROR ((LM_ERROR, "usage: %n [-p portnum] [-h host_name] [-r] [-f file]\n%a", 1)); +} + +void +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opt (argc, argv, "p:h:r:"); + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'h': + host_name = get_opt.optarg; + break; + case 'p': + port_number = ACE_OS::atoi (get_opt.optarg); + break; + case 'r': + remote_reconfigure = 1; + break; + default: + print_usage_and_die (); + break; + } +} + +int +main (int argc, char *argv[]) +{ + ACE_LOG_MSG->open (argv[0]); + + parse_args (argc, argv); + static char buf[BUFSIZ] = "help"; + int n; + ACE_SOCK_Stream sc; + ACE_SOCK_Connector con; + + if (con.connect (sc, ACE_INET_Addr (port_number, host_name)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n%a", "connect", 1), -1); + + if (remote_reconfigure) + ACE_OS::strcpy (buf, "reconfigure"); + + /* Send the command */ + + if (sc.send_n (buf, ACE_OS::strlen (buf) + 1) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n%a", "send", 1), -1); + + /* Next, read the response. */ + + while ((n = sc.recv (buf, sizeof buf)) > 0) + if (ACE_OS::write (ACE_STDOUT, buf, n) != n) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n%a", "write", 1), -1); + + if (sc.close () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n%a", "close", 1), -1); + + return 0; +} diff --git a/examples/Service_Configurator/IPC-tests/client/remote_stream_client_test.cpp b/examples/Service_Configurator/IPC-tests/client/remote_stream_client_test.cpp new file mode 100644 index 00000000000..80444b8da8e --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/client/remote_stream_client_test.cpp @@ -0,0 +1,105 @@ +/* Test program for the INET IPC-SAPs... */ +// @(#)remote_stream_client_test.cpp 1.1 10/18/96 + + +#include "ace/Mem_Map.h" +#include "ace/Log_Msg.h" +#include "ace/SOCK_Connector.h" +#include "ace/SOCK_CODgram.h" +#include "ace/INET_Addr.h" +#include "ace/Get_Opt.h" + +/* Name of the program. */ +static char *program_name; + +/* Port number to use. */ +static unsigned short port_number = ACE_DEFAULT_SERVER_PORT; + +/* Name of remote host. */ +static char *host_name = ACE_DEFAULT_SERVER_HOST; + +/* Name of file to send. */ +static char *file_name = "./remote_data"; + +static void +print_usage_and_die (void) +{ + ACE_ERROR ((LM_ERROR, "usage: %s [-p portnum] [-h host_name] [-f file]\n%a", + program_name, -1)); +} + +void +parse_args (int argc, char *argv[]) +{ + program_name = argv[0]; + ACE_Get_Opt get_opt (argc, argv, "f:h:p:"); + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'f': + file_name = get_opt.optarg; + break; + case 'h': + host_name = get_opt.optarg; + break; + case 'p': + port_number = ACE_OS::atoi (get_opt.optarg); + break; + default: + print_usage_and_die (); + break; + } +} + +int +main (int argc, char *argv[]) +{ + parse_args (argc, argv); + ACE_INET_Addr sa (port_number, host_name); + void *cp; + char buf[BUFSIZ]; + int n; + ACE_SOCK_CODgram dc; + + if (dc.open (sa, ACE_Addr::sap_any) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); + + /* First send the name of the file as a datagram. */ + + iovec iov[2]; + + iov[0].iov_base = "filename: "; + iov[0].iov_len = 11; + iov[1].iov_base = file_name; + iov[1].iov_len = ACE_OS::strlen (file_name); + + if (dc.send (iov, 2) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send"), -1); + + ACE_SOCK_Stream sc; + ACE_SOCK_Connector con; + + if (con.connect (sc, sa) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "connect"), -1); + + ACE_Mem_Map mmap (file_name); + + if (mmap (cp) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "mmap"), -1); + + /* Next, send the file's contents. */ + + if (sc.send_n (cp, mmap.size ()) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send_urg"), -1); + + if (sc.close_writer () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close_writer"), -1); + + if ((n = sc.recv_n (buf, sizeof buf)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "recv"), -1); + else + ACE_OS::write (ACE_STDOUT, buf, n); + + return 0; +} diff --git a/examples/Service_Configurator/IPC-tests/client/remote_thr_stream_client_test.cpp b/examples/Service_Configurator/IPC-tests/client/remote_thr_stream_client_test.cpp new file mode 100644 index 00000000000..18c6162c788 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/client/remote_thr_stream_client_test.cpp @@ -0,0 +1,96 @@ +/* Test program for the INET ACE_TLI-SAPs... */ +// @(#)remote_thr_stream_client_test.cpp 1.1 10/18/96 + + +#include "ace/Mem_Map.h" +#include "ace/TLI_Connector.h" +#include "ace/INET_Addr.h" +#include "ace/Log_Msg.h" +#include "ace/Log_Msg.h" +#include "ace/Get_Opt.h" + +#if defined (ACE_HAS_TLI) + +/* Name of the program. */ +static char *program_name; + +/* Port number to use. */ +static unsigned short port_number = ACE_DEFAULT_THR_PORT; + +/* Name of remote host. */ +static char *host_name = ACE_DEFAULT_SERVER_HOST; + +/* Name of file to send. */ +static char *file_name = "./remote_data"; + +static void print_usage_and_die (void) +{ + ACE_ERROR ((LM_ERROR, "usage: %s [-p portnum] [-h host_name] [-f file]\n%a", + program_name, -1)); +} + +void +parse_args (int argc, char *argv[]) +{ + program_name = argv[0]; + ACE_Get_Opt get_opt (argc, argv, "f:h:p:"); + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'f': + file_name = get_opt.optarg; + break; + case 'h': + host_name = get_opt.optarg; + break; + case 'p': + port_number = ACE_OS::atoi (get_opt.optarg); + break; + default: + print_usage_and_die (); + break; + } +} + +int +main (int argc, char *argv[]) +{ + parse_args (argc, argv); + void *cp; + char buf[BUFSIZ]; + ACE_TLI_Stream sc; + ACE_TLI_Connector con; + + if (con.connect (sc, ACE_INET_Addr (port_number, host_name)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); + + ACE_Mem_Map mmap (file_name, PROT_READ); + + if (mmap (cp) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "mmap"), -1); + + /* Next, send the file's contents. */ + + if (sc.send_n (cp, mmap.size ()) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send_n"), -1); + + if (sc.sndrel () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close_writer"), -1); + + for (int n; (n = sc.recv (buf, sizeof buf)) > 0; ) + if (ACE_OS::write (ACE_STDOUT, buf, n) != n) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "write"), -1); + + if (sc.close () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), -1); + + return 0; +} +#else +int +main (void) +{ + ACE_ERROR_RETURN ((LM_ERROR, "you must have TLI to run this test\n"), 1); +} +#endif /* ACE_HAS_TLI */ diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.cpp b/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.cpp new file mode 100644 index 00000000000..3e6f852a53d --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.cpp @@ -0,0 +1,36 @@ +#include "Handle_Broadcast.h" +// @(#)Handle_Broadcast.cpp 1.1 10/18/96 + + +#if defined (SunOS4) +extern "C" +{ + int init (void); + int fini (void); + void __sti__Handle_Broadcast_C_init_(); + void __std__Handle_Broadcast_C_init_(); +} + +int +init (void) +{ + __sti__Handle_Broadcast_C_init_(); + return 0; +} + +int +fini (void) +{ + __std__Handle_Broadcast_C_init_(); + return 0; +} +#endif /* SunOS4 */ + +unsigned short Handle_Broadcast::DEFAULT_PORT = ACE_DEFAULT_BROADCAST_PORT; + +#if !defined (__ACE_INLINE__) +#include "Handle_Broadcast.i" +#endif /* __ACE_INLINE__ */ + +Handle_Broadcast remote_broadcast; +ACE_Service_Object_Type rb (&remote_broadcast, "Remote_Brdcast"); diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.h b/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.h new file mode 100644 index 00000000000..3d22d6b473f --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.h @@ -0,0 +1,41 @@ +/* -*- C++ -*- */ +// @(#)Handle_Broadcast.h 1.1 10/18/96 + +/* Handles INET broadcast datagram messages from remote hosts on the local subnet. */ + +#if !defined (_HANDLE_BROADCAST_H) +#define _HANDLE_BROADCAST_H + +#include "ace/Service_Config.h" +#include "ace/Service_Record.h" +#include "ace/INET_Addr.h" +#include "ace/SOCK_Dgram.h" + +class Handle_Broadcast : public ACE_Service_Object, public ACE_SOCK_Dgram +{ +public: + Handle_Broadcast (void); + ~Handle_Broadcast (void); + virtual int init (int argc, char *argv[]); + virtual int info (char **, size_t) const; + virtual int fini (void); + +private: + int open (const ACE_INET_Addr &r, int async = 0); + virtual int get_handle (void) const; + virtual int handle_input (int fd); + virtual int handle_close (int fd, ACE_Reactor_Mask); + + static unsigned short DEFAULT_PORT; +}; + +extern ACE_Service_Object_Type rb; + +#if defined (__ACE_INLINE__) +#define ACE_INLINE inline +#include "Handle_Broadcast.i" +#else +#define ACE_INLINE +#endif /* __ACE_INLINE__ */ + +#endif /* _HANDLE_BROADCAST_H */ diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.i b/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.i new file mode 100644 index 00000000000..624ee1edb26 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.i @@ -0,0 +1,110 @@ +/* -*- C++ -*- */ +// @(#)Handle_Broadcast.i 1.1 10/18/96 + + +#include "ace/Get_Opt.h" + +ACE_INLINE +Handle_Broadcast::~Handle_Broadcast (void) +{ +} + +ACE_INLINE +Handle_Broadcast::Handle_Broadcast (void) +{ +} + +ACE_INLINE int +Handle_Broadcast::open (const ACE_INET_Addr &r, int async) +{ + if (this->ACE_SOCK_Dgram::open (r) == -1) + return -1; + else if (async && ACE_SOCK_Dgram::enable (SIGIO) == -1) + return -1; + else + return 0; +} + +ACE_INLINE int +Handle_Broadcast::info (char **strp, size_t length) const +{ + char buf[BUFSIZ]; + ACE_INET_Addr sa; + + if (this->get_local_addr (sa) == -1) + return -1; + + ACE_OS::sprintf (buf, "%d/%s %s", sa.get_port_number (), "udp", "# tests broadcasting\n"); + + if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) + return -1; + else + ACE_OS::strncpy (*strp, buf, length); + return ACE_OS::strlen (buf); +} + +ACE_INLINE int +Handle_Broadcast::init (int argc, char *argv[]) +{ + ACE_INET_Addr sba (Handle_Broadcast::DEFAULT_PORT); + ACE_Get_Opt get_opt (argc, argv, "p:", 0); + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'p': + sba.set (ACE_OS::atoi (get_opt.optarg)); + break; + default: + break; + } + + if (this->open (sba) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); + else if (ACE_Service_Config::reactor ()->register_handler + (this, ACE_Event_Handler::READ_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "registering service with ACE_Reactor\n"), -1); + return 0; +} + +ACE_INLINE int +Handle_Broadcast::fini (void) +{ + return ACE_Service_Config::reactor ()->remove_handler + (this, ACE_Event_Handler::READ_MASK); +} + +ACE_INLINE int +Handle_Broadcast::get_handle (void) const +{ + return this->ACE_SOCK_Dgram::get_handle (); +} + +ACE_INLINE int +Handle_Broadcast::handle_input (int) +{ + ACE_INET_Addr sa; + char buf[0x2000]; /* 8 k buffer */ + int n; + + if ((n = this->recv (buf, sizeof buf, sa)) == -1) + return -1; + else + ACE_DEBUG ((LM_INFO, "received broadcast datagram from host %s\n", sa.get_host_name ())); + + ACE_OS::puts ("----------------------------------------"); + ACE_OS::write (ACE_STDOUT, buf, n); + + if (buf[n - 1] != '\n') + putchar ('\n'); + + ACE_OS::puts ("----------------------------------------"); + + return 0; +} + +ACE_INLINE int +Handle_Broadcast::handle_close (int, ACE_Reactor_Mask) +{ + return this->ACE_SOCK_Dgram::close (); +} diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.cpp b/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.cpp new file mode 100644 index 00000000000..9750154c1b3 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.cpp @@ -0,0 +1,36 @@ +#include "Handle_L_CODgram.h" +// @(#)Handle_L_CODgram.cpp 1.1 10/18/96 + + +#if defined (SunOS4) +extern "C" +{ + int init (void); + int fini (void); + void __sti__Handle_L_CODgram_C_init_(); + void __std__Handle_L_CODgram_C_init_(); +} + +int +init (void) +{ + __sti__Handle_L_CODgram_C_init_(); + return 0; +} + +int +fini (void) +{ + __std__Handle_L_CODgram_C_init_(); + return 0; +} +#endif /* SunOS4 */ + +const char *Handle_L_CODgram::DEFAULT_RENDEZVOUS = "/tmp/foo_codgram"; + +#if !defined (__ACE_INLINE__) +#include "Handle_L_CODgram.i" +#endif /* __ACE_INLINE__ */ + +Handle_L_CODgram local_codgram; +ACE_Service_Object_Type lc (&local_codgram, "Local_CODgram"); diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.h b/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.h new file mode 100644 index 00000000000..0d2692c63d2 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.h @@ -0,0 +1,41 @@ +/* -*- C++ -*- */ +// @(#)Handle_L_CODgram.h 1.1 10/18/96 + +/* Handles UNIX datagram messages from local host. */ + +#if !defined (_HANDLE_L_CODGRAM_H) +#define _HANDLE_L_CODGRAM_H + +#include "ace/Service_Config.h" +#include "ace/Service_Record.h" +#include "ace/LSOCK_CODgram.h" +#include "ace/UNIX_Addr.h" + +class Handle_L_CODgram : public ACE_Service_Object, public ACE_LSOCK_CODgram +{ +public: + Handle_L_CODgram (void); + virtual int init (int argc, char *argv[]); + virtual int info (char **, size_t) const; + virtual int fini (void); + +public: + int open (const ACE_UNIX_Addr &suad, int async = 0); + virtual ACE_HANDLE get_handle (void) const; + virtual int handle_input (ACE_HANDLE); + virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask); + + char rendezvous[MAXPATHLEN + 1]; + static const char *DEFAULT_RENDEZVOUS; +}; + +extern ACE_Service_Object_Type lc; + +#if defined (__ACE_INLINE__) +#define ACE_INLINE inline +#include "Handle_L_CODgram.i" +#else +#define ACE_INLINE +#endif /* __ACE_INLINE__ */ + +#endif /* _HANDLE_L_CODGRAM_H */ diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.i b/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.i new file mode 100644 index 00000000000..6c69af48c20 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.i @@ -0,0 +1,113 @@ +/* -*- C++ -*- */ +// @(#)Handle_L_CODgram.i 1.1 10/18/96 + + +#include "ace/Get_Opt.h" + +ACE_INLINE +Handle_L_CODgram::Handle_L_CODgram (void) +{ +} + +ACE_INLINE int +Handle_L_CODgram::open (const ACE_UNIX_Addr &suad, int async) +{ + if (this->ACE_LSOCK_CODgram::open (ACE_Addr::sap_any, suad) == -1) + return -1; + else if (async && this->ACE_LSOCK_CODgram::enable (SIGIO) == -1) + return -1; + else + return 0; +} + +ACE_INLINE int +Handle_L_CODgram::info (char **strp, size_t length) const +{ + char buf[BUFSIZ]; + ACE_UNIX_Addr sa; + + if (ACE_LSOCK_CODgram::get_local_addr (sa) == -1) + return -1; + + ACE_OS::sprintf (buf, "%s %s", sa.get_path_name (), + "# tests local connected datagram\n"); + + if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) + return -1; + else + ACE_OS::strncpy (*strp, buf, length); + return ACE_OS::strlen (buf); +} + +ACE_INLINE int +Handle_L_CODgram::init (int argc, char *argv[]) +{ + ACE_UNIX_Addr sucd; + ACE_Get_Opt get_opt (argc, argv, "r:", 0); + const char *r = Handle_L_CODgram::DEFAULT_RENDEZVOUS; + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'r': + r = get_opt.optarg; + break; + default: + break; + } + + ACE_OS::strncpy (this->rendezvous, r, MAXPATHLEN); + ACE_OS::unlink (this->rendezvous); + sucd.set (this->rendezvous); + if (this->open (sucd) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); + else if (ACE_Service_Config::reactor ()->register_handler + (this, ACE_Event_Handler::READ_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "registering service with ACE_Reactor\n"), -1); + return 0; +} + +ACE_INLINE int +Handle_L_CODgram::fini(void) +{ + return ACE_Service_Config::reactor ()->remove_handler + (this, ACE_Event_Handler::READ_MASK); +} + +ACE_INLINE ACE_HANDLE +Handle_L_CODgram::get_handle (void) const +{ + return ACE_LSOCK_CODgram::get_handle (); +} + +ACE_INLINE int +Handle_L_CODgram::handle_input (ACE_HANDLE) +{ + ACE_HANDLE handle = ACE_INVALID_HANDLE; + char buf[BUFSIZ]; + + if (this->recv_handle (handle) == -1) + return -1; + else + ACE_DEBUG ((LM_INFO, "received handle (%d)\n", handle)); + + ACE_OS::puts ("----------------------------------------"); + + for (ssize_t n; n = ACE_OS::read (handle, buf, sizeof buf); ) + ACE_OS::write (ACE_STDOUT, buf, n); + + ACE_OS::puts ("----------------------------------------"); + + if (ACE_OS::close (handle) == -1) + return -1; + + return 0; +} + +ACE_INLINE int +Handle_L_CODgram::handle_close (ACE_HANDLE, ACE_Reactor_Mask) +{ + this->ACE_LSOCK_CODgram::close (); + return ACE_OS::unlink (this->rendezvous); +} diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.cpp b/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.cpp new file mode 100644 index 00000000000..f8615d3cd26 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.cpp @@ -0,0 +1,15 @@ +#include "Handle_L_Dgram.h" +// @(#)Handle_L_Dgram.cpp 1.1 10/18/96 + + +#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) + +const char *Handle_L_Dgram::DEFAULT_RENDEZVOUS = "/tmp/foo_dgram"; + +#if !defined (__ACE_INLINE__) +#include "Handle_L_Dgram.i" +#endif /* __ACE_INLINE__ */ + +Handle_L_Dgram local_dgram; +ACE_Service_Object_Type ld (&local_dgram, "Local_Dgram"); +#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */ diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.h b/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.h new file mode 100644 index 00000000000..72c2914ef6a --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.h @@ -0,0 +1,43 @@ +/* -*- C++ -*- */ +// @(#)Handle_L_Dgram.h 1.1 10/18/96 + +// Handles UNIX datagram messages from local host. + +#if !defined (_HANDLE_L_DGRAM_H) +#define _HANDLE_L_DGRAM_H + +#include "ace/Service_Config.h" +#include "ace/Service_Record.h" +#include "ace/LSOCK_Dgram.h" +#include "ace/UNIX_Addr.h" + +#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) + +class Handle_L_Dgram : public ACE_Service_Object, public ACE_LSOCK_Dgram +{ +public: + Handle_L_Dgram (void); + virtual int init (int argc, char *argv[]); + virtual int info (char **, size_t) const; + virtual int fini (void); + +private: + int open (const ACE_UNIX_Addr &suad, int async = 0); + virtual int get_handle (void) const; + virtual int handle_input (int fd); + virtual int handle_close (int fd, ACE_Reactor_Mask); + + char rendezvous[MAXPATHLEN + 1]; + static const char *DEFAULT_RENDEZVOUS; +}; + +extern ACE_Service_Object_Type ld; + +#if defined (__ACE_INLINE__) +#define ACE_INLINE inline +#include "Handle_L_Dgram.i" +#else +#define ACE_INLINE +#endif /* __ACE_INLINE__ */ +#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */ +#endif /* _HANDLE_L_DGRAM_H */ diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.i b/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.i new file mode 100644 index 00000000000..4133a0d6a4f --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.i @@ -0,0 +1,109 @@ +/* -*- C++ -*- */ +// @(#)Handle_L_Dgram.i 1.1 10/18/96 + + +#include "ace/Get_Opt.h" + +ACE_INLINE +Handle_L_Dgram::Handle_L_Dgram (void) +{ +} + +ACE_INLINE int +Handle_L_Dgram::open (const ACE_UNIX_Addr &suad, int async) +{ + if (this->ACE_LSOCK_Dgram::open (suad) == -1) + return -1; + else if (async && this->ACE_LSOCK_Dgram::enable (SIGIO) == -1) + return -1; + else + return 0; +} + +ACE_INLINE int +Handle_L_Dgram::info (char **strp, size_t length) const +{ + char buf[BUFSIZ]; + ACE_UNIX_Addr sa; + + if (this->ACE_LSOCK_Dgram::get_local_addr (sa) == -1) + return -1; + + ACE_OS::sprintf (buf, "%s %s", sa.get_path_name (), "# tests local datagram\n"); + + if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) + return -1; + else + ACE_OS::strncpy (*strp, buf, length); + return ACE_OS::strlen (buf); +} + +ACE_INLINE int +Handle_L_Dgram::init (int argc, char *argv[]) +{ + ACE_UNIX_Addr sudg; + ACE_Get_Opt get_opt (argc, argv, "r:", 0); + const char *r = Handle_L_Dgram::DEFAULT_RENDEZVOUS; + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'r': + r = get_opt.optarg; + break; + default: + break; + } + + ACE_OS::strncpy (this->rendezvous, r, MAXPATHLEN); + ACE_OS::unlink (this->rendezvous); + sudg.set (this->rendezvous); + if (this->open (sudg) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); + else if (ACE_Service_Config::reactor ()->register_handler (this, + ACE_Event_Handler::READ_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "registering service with ACE_Reactor\n"), -1); + return 0; +} + +ACE_INLINE int +Handle_L_Dgram::fini (void) +{ + return ACE_Service_Config::reactor ()->remove_handler (this, ACE_Event_Handler::READ_MASK); +} + +ACE_INLINE int +Handle_L_Dgram::get_handle (void) const +{ + return this->ACE_LSOCK_Dgram::get_handle (); +} + +ACE_INLINE int +Handle_L_Dgram::handle_input (int) +{ + ACE_UNIX_Addr sa; + char buf[8 * 1024]; /* 8 k buffer */ + int n; + + if ((n = this->recv (buf, sizeof buf, sa)) == -1) + return -1; + else + ACE_DEBUG ((LM_INFO, "received datagram from %s\n", sa.get_path_name ())); + + ACE_OS::puts ("----------------------------------------"); + ACE_OS::write (ACE_STDOUT, buf, n); + + if (buf[n - 1] != '\n') + putchar ('\n'); + + ACE_OS::puts ("----------------------------------------"); + + return 0; +} + +ACE_INLINE int +Handle_L_Dgram::handle_close (int, ACE_Reactor_Mask) +{ + this->ACE_LSOCK_Dgram::close (); + return ACE_OS::unlink (this->rendezvous); +} diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.cpp b/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.cpp new file mode 100644 index 00000000000..7106034f33f --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.cpp @@ -0,0 +1,36 @@ +#include "Handle_L_FIFO.h" +// @(#)Handle_L_FIFO.cpp 1.1 10/18/96 + + +#if defined (SunOS4) +extern "C" +{ + int init (void); + int fini (void); + void __sti__Handle_L_FIFO_C_init_(); + void __std__Handle_L_FIFO_C_init_(); +} + +int +init (void) +{ + __sti__Handle_L_FIFO_C_init_(); + return 0; +} + +int +fini (void) +{ + __std__Handle_L_FIFO_C_init_(); + return 0; +} +#endif /* SunOS4 */ + +const char *Handle_L_FIFO::DEFAULT_RENDEZVOUS = "/tmp/foo_fifo"; + +#if !defined (__ACE_INLINE__) +#include "Handle_L_FIFO.i" +#endif /* __ACE_INLINE__ */ + +Handle_L_FIFO local_fifo; +ACE_Service_Object_Type lf (&local_fifo, "Local_FIFO"); diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.h b/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.h new file mode 100644 index 00000000000..82ab2f5df51 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.h @@ -0,0 +1,42 @@ +/* -*- C++ -*- */ +// @(#)Handle_L_FIFO.h 1.1 10/18/96 + +/* Handle connections from local UNIX ACE_FIFO */ +/* Read from a well known ACE_FIFO and write to stdout. */ + +#if !defined (_HANDLE_L_FIFO_H) +#define _HANDLE_L_FIFO_H + +#include "ace/Service_Config.h" +#include "ace/Service_Record.h" +#include "ace/FIFO_Recv_Msg.h" + +class Handle_L_FIFO : public ACE_Service_Object, public ACE_FIFO_Recv_Msg +{ +public: + Handle_L_FIFO (void); + virtual int init (int argc, char *argv[]); + virtual int info (char **, size_t) const; + virtual int fini (void); + +private: + int open (const char *rendezvous_fifo); + virtual int get_handle (void) const; + virtual int handle_input (int fd); + virtual int handle_close (int fd, ACE_Reactor_Mask); + + static const char *DEFAULT_RENDEZVOUS; +}; + +extern ACE_Service_Object_Type lf; + +#if defined (__ACE_INLINE__) +#define ACE_INLINE inline +#include "Handle_L_FIFO.i" +#else +#define ACE_INLINE +#endif /* __ACE_INLINE__ */ + +#endif /* _HANDLE_L_FIFO_H */ + + diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.i b/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.i new file mode 100644 index 00000000000..6ba9f212d6c --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.i @@ -0,0 +1,94 @@ +/* -*- C++ -*- */ +// @(#)Handle_L_FIFO.i 1.1 10/18/96 + + +#include "ace/Get_Opt.h" + +ACE_INLINE +Handle_L_FIFO::Handle_L_FIFO (void) +{ +} + +ACE_INLINE int +Handle_L_FIFO::open (const char *rendezvous_fifo) +{ + if (this->ACE_FIFO_Recv_Msg::open (rendezvous_fifo) == -1) + return -1; + else + return 0; +} + +ACE_INLINE int +Handle_L_FIFO::info (char **strp, size_t length) const +{ + char buf[BUFSIZ]; + const char *rendezvous_fifo; + + this->get_local_addr (rendezvous_fifo); + + ACE_OS::sprintf (buf, "%s %s", rendezvous_fifo, "# tests local ACE_FIFO\n"); + + if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) + return -1; + else + ACE_OS::strncpy (*strp, buf, length); + return ACE_OS::strlen (buf); +} + +ACE_INLINE int +Handle_L_FIFO::init (int argc, char *argv[]) +{ + const char *rendezvous_fifo = Handle_L_FIFO::DEFAULT_RENDEZVOUS; + ACE_Get_Opt get_opt (argc, argv, "r:", 0); + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'r': + rendezvous_fifo = get_opt.optarg; + break; + default: + break; + } + + ACE_OS::unlink (rendezvous_fifo); + if (this->open (rendezvous_fifo) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); + else if (ACE_Service_Config::reactor ()->register_handler (this, + ACE_Event_Handler::READ_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "registering service with ACE_Reactor\n"), -1); + return 0; +} + +ACE_INLINE int +Handle_L_FIFO::fini (void) +{ + return ACE_Service_Config::reactor ()->remove_handler (this, ACE_Event_Handler::READ_MASK); +} + +ACE_INLINE int +Handle_L_FIFO::get_handle (void) const +{ + return this->ACE_FIFO::get_handle (); +} + +ACE_INLINE int +Handle_L_FIFO::handle_input (int) +{ + char buf[PIPE_BUF]; + ACE_Str_Buf msg (buf, 0, sizeof buf); + + /* Accept communication requests */ + if (this->recv (msg) == -1) + return -1; + else + + ACE_OS::write (ACE_STDOUT, (const char *) msg.buf, (int) msg.len); + return 0; +} + +ACE_INLINE int +Handle_L_FIFO::handle_close (int, ACE_Reactor_Mask) +{ + return this->ACE_FIFO::remove (); +} diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.cpp b/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.cpp new file mode 100644 index 00000000000..086f8c2e86c --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.cpp @@ -0,0 +1,36 @@ +#include "Handle_L_Pipe.h" +// @(#)Handle_L_Pipe.cpp 1.1 10/18/96 + + +#if defined (SunOS4) +extern "C" +{ + int init (void); + int fini (void); + void __sti__Handle_L_Pipe_C_recv_n_(); + void __std__Handle_L_Pipe_C_recv_n_(); +} + +int +init (void) +{ + __sti__Handle_L_Pipe_C_recv_n_(); + return 0; +} + +int +fini (void) +{ + __std__Handle_L_Pipe_C_recv_n_(); + return 0; +} +#endif /* SunOS4 */ + +const char *Handle_L_Pipe::DEFAULT_RENDEZVOUS = "/tmp/foo_pipe"; + +#if !defined (__ACE_INLINE__) +#include "Handle_L_Pipe.i" +#endif /* __ACE_INLINE__ */ + +Handle_L_Pipe local_pipe; +ACE_Service_Object_Type lp (&local_pipe, "Local_Pipe"); diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.h b/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.h new file mode 100644 index 00000000000..ffd7651048a --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.h @@ -0,0 +1,44 @@ +/* -*- C++ -*- */ +// @(#)Handle_L_Pipe.h 1.1 10/18/96 + +/* Handle connections from local UNIX domain sockets that are sending + end-points from a pipe! */ + +#if !defined (_HANDLE_L_PIPE_H) +#define _HANDLE_L_PIPE_H + +#include "ace/Service_Config.h" +#include "ace/Service_Record.h" +#include "ace/UNIX_Addr.h" +#include "ace/LSOCK_Acceptor.h" + +class Handle_L_Pipe : public ACE_Service_Object, public ACE_LSOCK_Acceptor +{ +public: + Handle_L_Pipe (void); + ~Handle_L_Pipe (void); + virtual int init (int argc, char *argv[]); + virtual int info (char **, size_t) const; + virtual int fini (void); + +private: + int open (const ACE_UNIX_Addr &suap, int async = 0); + virtual ACE_HANDLE get_handle (void) const; + virtual int handle_input (ACE_HANDLE fd); + virtual int handle_close (ACE_HANDLE fd, ACE_Reactor_Mask); + + char rendezvous[MAXPATHLEN + 1]; + static const char *DEFAULT_RENDEZVOUS; +}; + +extern ACE_Service_Object_Type lp; + +#if defined (__ACE_INLINE__) +#define ACE_INLINE inline +#include "Handle_L_Pipe.i" +#else +#define ACE_INLINE +#endif /* __ACE_INLINE__ */ + +#endif /* _HANDLE_L_PIPE_H */ + diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.i b/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.i new file mode 100644 index 00000000000..b5c430a8e51 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.i @@ -0,0 +1,136 @@ +/* -*- C++ -*- */ +// @(#)Handle_L_Pipe.i 1.1 10/18/96 + + +#include "ace/Get_Opt.h" + +ACE_INLINE +Handle_L_Pipe::~Handle_L_Pipe (void) +{ +} + +/* Uppercase N bytes of S. */ + +static char * +upper_case (char s[], int n) +{ + while (--n >= 0) + if (islower (s[n])) + s[n] = toupper (s[n]); + + return s; +} + +ACE_INLINE +Handle_L_Pipe::Handle_L_Pipe (void) +{ +} + +ACE_INLINE int +Handle_L_Pipe::open (const ACE_UNIX_Addr &suap, int async) +{ + if (this->ACE_LSOCK_Acceptor::open (suap) == -1) + return -1; + else if (async && this->ACE_LSOCK_Acceptor::enable (SIGIO) == -1) + return -1; + else + return 0; +} + +ACE_INLINE int +Handle_L_Pipe::info (char **strp, size_t length) const +{ + char buf[BUFSIZ]; + ACE_UNIX_Addr sa; + + if (ACE_LSOCK_Acceptor::get_local_addr (sa) == -1) + return -1; + + ACE_OS::sprintf (buf, "%s %s", sa.get_path_name (), "# tests local pipe\n"); + + if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) + return -1; + else + ACE_OS::strncpy (*strp, buf, length); + return ACE_OS::strlen (buf); +} + +ACE_INLINE int +Handle_L_Pipe::init (int argc, char *argv[]) +{ + ACE_UNIX_Addr sup; + const char *r = Handle_L_Pipe::DEFAULT_RENDEZVOUS; + ACE_Get_Opt get_opt (argc, argv, "r:", 0); + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'r': + r = get_opt.optarg; + break; + default: + break; + } + + ACE_OS::strncpy (this->rendezvous, r, MAXPATHLEN); + ACE_OS::unlink (this->rendezvous); + sup.set (this->rendezvous); + if (this->open (sup) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); + else if (ACE_Service_Config::reactor ()->register_handler + (this, ACE_Event_Handler::READ_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "registering service with ACE_Reactor\n"), -1); + return 0; +} + +ACE_INLINE int +Handle_L_Pipe::fini (void) +{ + return ACE_Service_Config::reactor ()->remove_handler + (this, ACE_Event_Handler::READ_MASK); +} + +ACE_INLINE int +Handle_L_Pipe::get_handle (void) const +{ + return ACE_LSOCK_Acceptor::get_handle (); +} + +ACE_INLINE int +Handle_L_Pipe::handle_input (ACE_HANDLE) +{ + ACE_LSOCK_Stream new_local_stream; + int n; + ACE_HANDLE fd1 = ACE_INVALID_HANDLE; + ACE_HANDLE fd2 = ACE_INVALID_HANDLE; + char buf[BUFSIZ]; + + if (this->accept (new_local_stream) == -1) + return -1; + + if (new_local_stream.recv_handle (fd1) == -1 + || new_local_stream.recv_handle (fd2) == -1) + return -1; + else + ACE_DEBUG ((LM_INFO, "received file descriptors %d and %d\n", fd1, fd2)); + + if ((n = ACE_OS::read (fd1, buf, sizeof buf)) == -1) + return -1; + else if (ACE_OS::write (fd2, upper_case (buf, n), n) == -1) + return -1; + if (ACE_OS::close (fd1) == -1 + || ACE_OS::close (fd2) == -1) + return -1; + if (new_local_stream.close () == -1) + return -1; + + return 0; +} + +ACE_INLINE int +Handle_L_Pipe::handle_close (ACE_HANDLE, ACE_Reactor_Mask) +{ + this->ACE_LSOCK_Acceptor::close (); + return ACE_OS::unlink (this->rendezvous); +} diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.cpp b/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.cpp new file mode 100644 index 00000000000..bd34890dbbc --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.cpp @@ -0,0 +1,16 @@ +#include "Handle_L_SPIPE.h" +// @(#)Handle_L_SPIPE.cpp 1.1 10/18/96 + + +#if !defined (__ACE_INLINE__) +#include "Handle_L_SPIPE.i" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_HAS_STREAM_PIPES) + +const char *Handle_L_SPIPE::DEFAULT_RENDEZVOUS = "/tmp/foo_spipe"; + +Handle_L_SPIPE local_spipe; +ACE_Service_Object_Type lsp (&local_spipe, "Local_SPIPE"); + +#endif /* ACE_HAS_STREAM_PIPES */ diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.h b/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.h new file mode 100644 index 00000000000..a844764d0dd --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.h @@ -0,0 +1,45 @@ +/* -*- C++ -*- */ +// @(#)Handle_L_SPIPE.h 1.1 10/18/96 + +/* Handle connections from local UNIX ACE_SPIPE */ +/* Read from a well known ACE_SPIPE and write to stdout. */ + +#if !defined (_HANDLE_L_SPIPE_H) +#define _HANDLE_L_SPIPE_H + +#include "ace/Service_Config.h" +#include "ace/Service_Record.h" +#include "ace/SPIPE_Acceptor.h" + +#if defined (ACE_HAS_STREAM_PIPES) + +class Handle_L_SPIPE : public ACE_Service_Object, public ACE_SPIPE_Acceptor +{ +public: + Handle_L_SPIPE (void); + virtual int init (int argc, char *argv[]); + virtual int info (char **, size_t) const; + virtual int fini (void); + +private: + int open (const ACE_SPIPE_Addr &rendezvous_spipe); + virtual int get_handle (void) const; + virtual int handle_input (int fd); + virtual int handle_close (int fd, ACE_Reactor_Mask); + + static const char *DEFAULT_RENDEZVOUS; +}; + +extern ACE_Service_Object_Type lsp; + +#if defined (__ACE_INLINE__) +#define ACE_INLINE inline +#include "Handle_L_SPIPE.i" +#else +#define ACE_INLINE +#endif /* __ACE_INLINE__ */ + +#endif /* _HANDLE_L_SPIPE_H */ + + +#endif /* ACE_HAS_STREAM_PIPES */ diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.i b/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.i new file mode 100644 index 00000000000..0d5e77e1b01 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.i @@ -0,0 +1,118 @@ +/* -*- C++ -*- */ +// @(#)Handle_L_SPIPE.i 1.1 10/18/96 + + +#include "ace/SPIPE_Stream.h" +#include "ace/Get_Opt.h" + +#if defined (ACE_HAS_STREAM_PIPES) + +ACE_INLINE +Handle_L_SPIPE::Handle_L_SPIPE (void) +{ +} + +ACE_INLINE int +Handle_L_SPIPE::open (const ACE_SPIPE_Addr &rendezvous_spipe) +{ + if (this->ACE_SPIPE_Acceptor::open (rendezvous_spipe) == -1) + return -1; + else + return 0; +} + +ACE_INLINE int +Handle_L_SPIPE::info (char **strp, size_t length) const +{ + char buf[BUFSIZ]; + ACE_SPIPE_Addr sa; + + if (ACE_SPIPE_Acceptor::get_local_addr (sa) == -1) + return -1; + + ACE_OS::sprintf (buf, "%s %s", sa.get_path_name (), "# tests local STREAM pipe\n"); + + if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) + return -1; + else + ACE_OS::strncpy (*strp, buf, length); + return ACE_OS::strlen (buf); +} + +ACE_INLINE int +Handle_L_SPIPE::init (int argc, char *argv[]) +{ + ACE_SPIPE_Addr susp; + const char *rendezvous = Handle_L_SPIPE::DEFAULT_RENDEZVOUS; + ACE_Get_Opt get_opt (argc, argv, "r:", 0); + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'r': + rendezvous = get_opt.optarg; + break; + default: + break; + } + + ACE_OS::unlink (rendezvous); + susp.set (rendezvous); + if (this->open (susp) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); + else if (ACE_Service_Config::reactor ()->register_handler (this, + ACE_Event_Handler::READ_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "registering service with ACE_Reactor\n"), -1); + return 0; +} + +ACE_INLINE int +Handle_L_SPIPE::fini (void) +{ + return ACE_Service_Config::reactor ()->remove_handler (this, ACE_Event_Handler::READ_MASK); +} + +ACE_INLINE int +Handle_L_SPIPE::get_handle (void) const +{ + return ACE_SPIPE::get_handle(); +} + +ACE_INLINE int +Handle_L_SPIPE::handle_input (int) +{ + ACE_SPIPE_Stream new_spipe; + char buf[PIPE_BUF]; + ACE_Str_Buf msg (buf, 0, sizeof buf); + int flags = 0; + + /* Accept communication requests */ + if (this->ACE_SPIPE_Acceptor::accept (new_spipe) == -1) + return -1; + else + { + ACE_SPIPE_Addr sa; + + new_spipe.get_remote_addr (sa); + + ACE_DEBUG ((LM_INFO, "accepted request from %s (gid = %d, uid = %d)\n", + sa.get_path_name (), sa.group_id (), sa.user_id ())); + } + + while (new_spipe.recv ((ACE_Str_Buf *) 0, &msg, &flags) >= 0) + if (msg.len != 0) + ACE_OS::write (ACE_STDOUT, (const char *) msg.buf, (int) msg.len); + else + break; + + if (new_spipe.close () == -1) + return -1; + return 0; +} + +ACE_INLINE int +Handle_L_SPIPE::handle_close (int, ACE_Reactor_Mask) +{ + return this->ACE_SPIPE_Acceptor::remove (); +} +#endif /* ACE_HAS_STREAM_PIPES */ diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.cpp b/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.cpp new file mode 100644 index 00000000000..e9b2ba2483b --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.cpp @@ -0,0 +1,17 @@ +#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) +// @(#)Handle_L_Stream.cpp 1.1 10/18/96 + +#include "Handle_L_Stream.h" + +/* Static variables. */ + +const char *Handle_L_Stream::DEFAULT_RENDEZVOUS = "/tmp/foo_stream"; +char *Handle_L_Stream::login_name = 0; + +#if !defined (__ACE_INLINE__) +#include "Handle_L_Stream.i" +#endif /* __ACE_INLINE__ */ + +Handle_L_Stream local_stream; +ACE_Service_Object_Type ls (&local_stream, "Local_Stream"); +#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */ diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.h b/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.h new file mode 100644 index 00000000000..b06b914cfd4 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.h @@ -0,0 +1,48 @@ +/* -*- C++ -*- */ +// @(#)Handle_L_Stream.h 1.1 10/18/96 + + +/* Handle connections from local UNIX domain sockets. */ + +#if !defined (_HANDLE_L_STREAM_H) +#define _HANDLE_L_STREAM_H + +#include "ace/Service_Config.h" +#include "ace/Service_Record.h" +#include "ace/UNIX_Addr.h" +#include "ace/LSOCK_Acceptor.h" + +#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) + +class Handle_L_Stream : public ACE_Service_Object, public ACE_LSOCK_Acceptor +{ +public: + Handle_L_Stream (void); + ~Handle_L_Stream (void); + virtual int init (int argc, char *argv[]); + virtual int info (char **, size_t) const; + virtual int fini (void); + +private: + int open (const ACE_UNIX_Addr &suas, int async = 0); + virtual ACE_HANDLE get_handle (void) const; + virtual int handle_input (ACE_HANDLE fd); + virtual int handle_close (ACE_HANDLE fd, ACE_Reactor_Mask); + + char rendezvous[MAXPATHLEN + 1]; + static char *login_name; + static const char *DEFAULT_RENDEZVOUS; +}; + +extern ACE_Service_Object_Type ls; + +#if defined (__ACE_INLINE__) +#define ACE_INLINE inline +#include "Handle_L_Stream.i" +#else +#define ACE_INLINE +#endif /* __ACE_INLINE__ */ +#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */ +#endif /* _HANDLE_L_STREAM_H */ + + diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.i b/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.i new file mode 100644 index 00000000000..e0ef5373b0b --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.i @@ -0,0 +1,134 @@ +/* -*- C++ -*- */ +// @(#)Handle_L_Stream.i 1.1 10/18/96 + + +#include "ace/Get_Opt.h" + +ACE_INLINE +Handle_L_Stream::~Handle_L_Stream (void) +{ +} + +ACE_INLINE +Handle_L_Stream::Handle_L_Stream (void) +{ + if (Handle_L_Stream::login_name == 0) + Handle_L_Stream::login_name = ACE_OS::cuserid (0); +} + +ACE_INLINE int +Handle_L_Stream::open (const ACE_UNIX_Addr &suas, int async) +{ + if (this->ACE_LSOCK_Acceptor::open (suas) == -1) + return -1; + else if (async && this->ACE_LSOCK_Acceptor::enable (SIGIO) == -1) + return -1; + else + return 0; +} + +ACE_INLINE int +Handle_L_Stream::info (char **strp, size_t length) const +{ + char buf[BUFSIZ]; + ACE_UNIX_Addr sa; + + if (this->get_local_addr (sa) == -1) + return -1; + + ACE_OS::sprintf (buf, "%s %s", sa.get_path_name (), + "# tests local ACE_Stream\n"); + + if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) + return -1; + else + ACE_OS::strncpy (*strp, buf, length); + return ACE_OS::strlen (buf); +} + +ACE_INLINE int +Handle_L_Stream::init (int argc, char *argv[]) +{ + ACE_UNIX_Addr sus; + const char *r = Handle_L_Stream::DEFAULT_RENDEZVOUS; + ACE_Get_Opt get_opt (argc, argv, "r:", 0); + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'r': + r = get_opt.optarg; + break; + default: + break; + } + + ACE_OS::strncpy (this->rendezvous, r, MAXPATHLEN); + ACE_OS::unlink (this->rendezvous); + sus.set (this->rendezvous); + if (this->open (sus) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); + else if (ACE_Service_Config::reactor ()->register_handler (this, + ACE_Event_Handler::READ_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "registering service with ACE_Reactor\n"), -1); + return 0; +} + +ACE_INLINE int +Handle_L_Stream::fini (void) +{ + return ACE_Service_Config::reactor ()->remove_handler (this, ACE_Event_Handler::READ_MASK); +} + +ACE_INLINE ACE_HANDLE +Handle_L_Stream::get_handle (void) const +{ + return ACE_LSOCK_Acceptor::get_handle (); +} + +ACE_INLINE int +Handle_L_Stream::handle_input (ACE_HANDLE) +{ + ACE_LSOCK_Stream new_local_stream; + ACE_UNIX_Addr sa; + int fd = ACE_INVALID_HANDLE; + char buf[BUFSIZ]; + + if (this->accept (new_local_stream, &sa) == -1) + return -1; + + if (new_local_stream.recv_handle (fd) == -1) + return -1; + else + ACE_DEBUG ((LM_INFO, + "received file descriptor %d on ACE_Stream %s\n", + fd, sa.get_path_name ())); + + ACE_OS::puts ("----------------------------------------"); + + for (ssize_t n; n = ACE_OS::read (fd, buf, sizeof buf); ) + ACE_OS::write (ACE_STDOUT, buf, n); + + ACE_OS::puts ("----------------------------------------"); + + time_t t = ACE_OS::time (0L); + char *cs = ACE_OS::ctime (&t); + + if (new_local_stream.send (4, + Handle_L_Stream::login_name, ACE_OS::strlen (Handle_L_Stream::login_name), + cs, ACE_OS::strlen (cs)) == -1) + return -1; + + if (ACE_OS::close (fd) == -1) + return -1; + if (new_local_stream.close () == -1) + return -1; + return 0; +} + +ACE_INLINE int +Handle_L_Stream::handle_close (ACE_HANDLE, ACE_Reactor_Mask) +{ + this->ACE_LSOCK_Acceptor::close (); + return ACE_OS::unlink (this->rendezvous); +} diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.cpp b/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.cpp new file mode 100644 index 00000000000..b5a3622a5ba --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.cpp @@ -0,0 +1,36 @@ +#include "Handle_R_Dgram.h" +// @(#)Handle_R_Dgram.cpp 1.1 10/18/96 + + +#if defined (SunOS4) +extern "C" +{ + int init (void); + int fini (void); + void __sti__Handle_R_Dgram_C_init_(); + void __std__Handle_R_Dgram_C_init_(); +} + +int +init (void) +{ + __sti__Handle_R_Dgram_C_init_(); + return 0; +} + +int +fini (void) +{ + __std__Handle_R_Dgram_C_init_(); + return 0; +} +#endif /* SunOS4 */ + +unsigned short Handle_R_Dgram::DEFAULT_PORT = ACE_DEFAULT_SERVER_PORT; + +#if !defined (__ACE_INLINE__) +#include "Handle_R_Dgram.i" +#endif /* __ACE_INLINE__ */ + +Handle_R_Dgram remote_dgram; +ACE_Service_Object_Type rd (&remote_dgram, "Remote_Dgram"); diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.h b/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.h new file mode 100644 index 00000000000..493a4c85d7a --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.h @@ -0,0 +1,40 @@ +/* -*- C++ -*- */ +// @(#)Handle_R_Dgram.h 1.1 10/18/96 + +/* Handles INET datagram messages from remote hosts. */ + +#if !defined (_HANDLE_R_DGRAM_H) +#define _HANDLE_R_DGRAM_H + +#include "ace/Service_Config.h" +#include "ace/Service_Record.h" +#include "ace/INET_Addr.h" +#include "ace/SOCK_Dgram.h" + +class Handle_R_Dgram : public ACE_Service_Object, public ACE_SOCK_Dgram +{ +public: + Handle_R_Dgram (void); + virtual int init (int argc, char *argv[]); + virtual int info (char **, size_t) const; + virtual int fini (void); + +private: + int open (const ACE_INET_Addr &r, int async = 0); + virtual int get_handle (void) const; + virtual int handle_input (int fd); + virtual int handle_close (int fd, ACE_Reactor_Mask); + + static unsigned short DEFAULT_PORT; +}; + +extern ACE_Service_Object_Type rd; + +#if defined (__ACE_INLINE__) +#define ACE_INLINE inline +#include "Handle_R_Dgram.i" +#else +#define ACE_INLINE +#endif /* __ACE_INLINE__ */ + +#endif /* _HANDLE_R_DGRAM_H */ diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.i b/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.i new file mode 100644 index 00000000000..9cefc302b00 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.i @@ -0,0 +1,106 @@ +/* -*- C++ -*- */ +// @(#)Handle_R_Dgram.i 1.1 10/18/96 + + +#include "ace/Get_Opt.h" + +ACE_INLINE +Handle_R_Dgram::Handle_R_Dgram (void) +{ +} + +ACE_INLINE +Handle_R_Dgram::open (const ACE_INET_Addr &r, int async) +{ + if (this->ACE_SOCK_Dgram::open (r) == -1) + return -1; + else if (async && this->ACE_SOCK_Dgram::enable (SIGIO) == -1) + return -1; + else + return 0; +} + +ACE_INLINE int +Handle_R_Dgram::info (char **strp, size_t length) const +{ + char buf[BUFSIZ]; + ACE_INET_Addr sa; + + if (this->get_local_addr (sa) == -1) + return -1; + + ACE_OS::sprintf (buf, "%d/%s %s", sa.get_port_number (), "udp", "# tests remote dgram\n"); + + if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) + return -1; + else + ACE_OS::strncpy (*strp, buf, length); + return ACE_OS::strlen (buf); +} + +ACE_INLINE int +Handle_R_Dgram::init (int argc, char *argv[]) +{ + ACE_INET_Addr sidg (Handle_R_Dgram::DEFAULT_PORT); + ACE_Get_Opt get_opt (argc, argv, "p:", 0); + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'p': + sidg.set (ACE_OS::atoi (get_opt.optarg)); + break; + default: + break; + } + + if (this->open (sidg) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); + else if (ACE_Service_Config::reactor ()->register_handler + (this, ACE_Event_Handler::READ_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "registering service with ACE_Reactor\n"), -1); + return 0; +} + +ACE_INLINE int +Handle_R_Dgram::fini (void) +{ + return ACE_Service_Config::reactor ()->remove_handler + (this, ACE_Event_Handler::READ_MASK); +} + +ACE_INLINE int +Handle_R_Dgram::get_handle (void) const +{ + return ACE_SOCK_Dgram::get_handle (); +} + +ACE_INLINE int +Handle_R_Dgram::handle_input (int) +{ + ACE_INET_Addr sa; + char buf[0x2000]; /* 8 k buffer */ + int n; + + if ((n = this->recv (buf, sizeof buf, sa)) == -1) + return -1; + else + ACE_DEBUG ((LM_INFO, "received datagram from host %s on port %d\n", + sa.get_host_name (), sa.get_port_number ())); + + ACE_OS::puts ("----------------------------------------"); + ACE_OS::write (ACE_STDOUT, buf, n); + + if (buf[n - 1] != '\n') + putchar ('\n'); + + ACE_OS::puts ("----------------------------------------"); + + return 0; +} + +ACE_INLINE int +Handle_R_Dgram::handle_close (int, ACE_Reactor_Mask) +{ + return this->ACE_SOCK_Dgram::close (); +} diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.cpp b/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.cpp new file mode 100644 index 00000000000..91549a321e8 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.cpp @@ -0,0 +1,39 @@ +#include "Handle_R_Stream.h" +// @(#)Handle_R_Stream.cpp 1.1 10/18/96 + + +#if defined (SunOS4) +extern "C" +{ + int init (void); + int fini (void); + void __sti__Handle_R_Stream_C_recv_n_(); + void __std__Handle_R_Stream_C_recv_n_(); +} + +int +init (void) +{ + __sti__Handle_R_Stream_C_recv_n_(); + return 0; +} + +int +fini (void) +{ + __std__Handle_R_Stream_C_recv_n_(); + return 0; +} +#endif /* SunOS4 */ + +/* Static variables. */ + +unsigned short Handle_R_Stream::DEFAULT_PORT = ACE_DEFAULT_SERVER_PORT; +char *Handle_R_Stream::login_name = 0; + +#if !defined (__ACE_INLINE__) +#include "Handle_R_Stream.i" +#endif /* __ACE_INLINE__ */ + +Handle_R_Stream remote_stream; +ACE_Service_Object_Type rs (&remote_stream, "Remote_Stream"); diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.h b/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.h new file mode 100644 index 00000000000..a612eb29ad5 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.h @@ -0,0 +1,46 @@ +/* -*- C++ -*- */ +// @(#)Handle_R_Stream.h 1.1 10/18/96 + +/* Handle connections from remote INET connections. */ + +#if !defined (_HANDLE_R_STREAM_H) +#define _HANDLE_R_STREAM_H + +#include "ace/Service_Config.h" +#include "ace/Service_Record.h" +#include "ace/SOCK_Stream.h" +#include "ace/SOCK_Acceptor.h" +#include "ace/INET_Addr.h" + +class Handle_R_Stream : public ACE_Service_Object, public ACE_SOCK_Acceptor +{ +public: + Handle_R_Stream (void); + virtual int init (int argc, char *argv[]); + virtual int info (char **, size_t) const; + virtual int fini (void); + +private: + int open (const ACE_INET_Addr &sia, int async = 0); + virtual int get_handle (void) const; + virtual int handle_input (int fd); + virtual int handle_close (int fd, ACE_Reactor_Mask); + + ACE_SOCK_Stream new_remote_stream; + static u_short DEFAULT_PORT; + static char *login_name; +}; + +extern ACE_Service_Object_Type rs; + +#if defined (__ACE_INLINE__) +#define ACE_INLINE inline +#include "Handle_R_Stream.i" +#else +#define ACE_INLINE +#endif /* __ACE_INLINE__ */ + +#endif /* _HANDLE_R_STREAM_H */ + + + diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.i b/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.i new file mode 100644 index 00000000000..ce605be5180 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.i @@ -0,0 +1,124 @@ +/* -*- C++ -*- */ +// @(#)Handle_R_Stream.i 1.1 10/18/96 + + +#include "ace/Get_Opt.h" + +ACE_INLINE +Handle_R_Stream::Handle_R_Stream (void) +{ + if (Handle_R_Stream::login_name == 0) + Handle_R_Stream::login_name = ACE_OS::cuserid (0); +} + +ACE_INLINE int +Handle_R_Stream::open (const ACE_INET_Addr &sia, int async) +{ + if (this->ACE_SOCK_Acceptor::open (sia) == -1) + return -1; + else if (async && this->ACE_SOCK_Acceptor::enable (SIGIO) == -1) + return -1; + else + return 0; +} + +ACE_INLINE int +Handle_R_Stream::info (char **strp, size_t length) const +{ + char buf[BUFSIZ]; + ACE_INET_Addr sa; + + if (this->get_local_addr (sa) == -1) + return -1; + + ACE_OS::sprintf (buf, "%d/%s %s", sa.get_port_number (), "tcp", "# tests remote stream\n"); + + if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) + return -1; + else + ACE_OS::strncpy (*strp, buf, length); + return ACE_OS::strlen (buf); +} + +ACE_INLINE int +Handle_R_Stream::init (int argc, char *argv[]) +{ + ACE_INET_Addr sis (Handle_R_Stream::DEFAULT_PORT); + ACE_Get_Opt get_opt (argc, argv, "p:", 0); + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'p': + sis.set (ACE_OS::atoi (get_opt.optarg)); + break; + default: + break; + } + + if (this->open (sis) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); + else if (ACE_Service_Config::reactor ()->register_handler (this, + ACE_Event_Handler::READ_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "registering service with ACE_Reactor\n"), -1); + return 0; +} + +ACE_INLINE int +Handle_R_Stream::fini (void) +{ + return ACE_Service_Config::reactor ()->remove_handler (this, ACE_Event_Handler::READ_MASK); +} + +ACE_INLINE int +Handle_R_Stream::get_handle (void) const +{ + return ACE_SOCK_Acceptor::get_handle (); +} + +ACE_INLINE int +Handle_R_Stream::handle_input (int) +{ + char buf[BUFSIZ]; + int bytes; + + if (this->accept (this->new_remote_stream) == -1) + return -1; + else + ACE_DEBUG ((LM_INFO, "new_remote_stream fd = %d\n", + this->new_remote_stream.get_handle ())); + + ACE_INET_Addr sa; + + if (this->new_remote_stream.get_remote_addr (sa) == -1) + return -1; + + ACE_DEBUG ((LM_INFO, "accepted from host %s at port %d\n", + sa.get_host_name (), sa.get_port_number ())); + + ACE_OS::puts ("----------------------------------------"); + + while ((bytes = this->new_remote_stream.recv (buf, sizeof buf)) > 0) + ACE_OS::write (ACE_STDOUT, buf, bytes); + + ACE_OS::puts ("----------------------------------------"); + + time_t t = ACE_OS::time (0L); + char *cs = ACE_OS::ctime (&t); + + if (this->new_remote_stream.send (4, + Handle_R_Stream::login_name, ACE_OS::strlen (Handle_R_Stream::login_name), + cs, ACE_OS::strlen (cs)) == -1) + return -1; + + if (this->new_remote_stream.close () == -1) + return -1; + + return 0; +} + +ACE_INLINE int +Handle_R_Stream::handle_close (int, ACE_Reactor_Mask) +{ + return this->ACE_SOCK_Acceptor::close (); +} diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.cpp b/examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.cpp new file mode 100644 index 00000000000..339ab3023b8 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.cpp @@ -0,0 +1,200 @@ +#if !defined (ACE_HANDLE_THR_STREAM_C) +// @(#)Handle_Thr_Stream.cpp 1.1 10/18/96 + +#define ACE_HANDLE_THR_STREAM_C + +#include "ace/Get_Opt.h" +#include "ace/INET_Addr.h" +#include "Handle_Thr_Stream.h" + +#if defined (ACE_HAS_THREADS) + +#if !defined (__ACE_INLINE__) +#include "Handle_Thr_Stream.i" +#endif /* __ACE_INLINE__ */ + +// Shorthand names. +#define SH SVC_HANDLER +#define PR_AC_1 ACE_PEER_ACCEPTOR_1 +#define PR_AC_2 ACE_PEER_ACCEPTOR_2 +#define PR_ST_1 ACE_PEER_STREAM_1 +#define PR_ST_2 ACE_PEER_STREAM_2 + +template <class SH, PR_AC_1> +Handle_Thr_Stream<SH, PR_AC_2>::~Handle_Thr_Stream (void) +{ +} + +template <class SH, PR_AC_1> +Handle_Thr_Stream<SH, PR_AC_2>::Handle_Thr_Stream (void) +#if defined (ACE_HAS_THREADS) + : thr_flags_ (THR_DETACHED | THR_NEW_LWP) +#else + : thr_flags_ (0) +#endif /* ACE_HAS_THREADS */ +{ +} + +template <class SH, PR_AC_1> int +Handle_Thr_Stream<SH, PR_AC_2>::info (char **strp, + size_t length) const +{ + char buf[BUFSIZ]; + ACE_INET_Addr sa; + + if (this->acceptor ().get_local_addr (sa) == -1) + return -1; + + ACE_OS::sprintf (buf, "%d/%s %s", sa.get_port_number (), "tcp", + "# tests threaded remote stream\n"); + + if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) + return -1; + else + ACE_OS::strncpy (*strp, buf, length); + return ACE_OS::strlen (buf); +} + +template <class SH, PR_AC_1> int +Handle_Thr_Stream<SH, PR_AC_2>::init (int argc, char *argv[]) +{ + ACE_INET_Addr local_addr (inherited::DEFAULT_PORT_); + int n_threads = ACE_DEFAULT_THREADS; + + ACE_Get_Opt get_opt (argc, argv, "p:t:", 0); + + for (int c; (c = get_opt ()) != -1; ) + { + switch (c) + { + case 'p': + local_addr.set (ACE_OS::atoi (get_opt.optarg)); + break; + case 't': + n_threads = ACE_OS::atoi (get_opt.optarg); + break; + default: + break; + } + } + + // Initialize the threading strategy. + if (this->thr_strategy_.open (&this->thr_mgr_, + this->thr_flags_, + n_threads) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); + + // Initialize the Acceptor base class, passing in the desired + // concurrency strategy. + else if (this->open (local_addr, ACE_Service_Config::reactor (), + 0, 0, &this->thr_strategy_) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); + else + return 0; +} + +template <class SH, PR_AC_1> int +Handle_Thr_Stream<SH, PR_AC_2>::fini (void) +{ + return ACE_Service_Config::reactor ()->remove_handler + (this, ACE_Event_Handler::READ_MASK); +} + +template <PR_ST_1> +CLI_Stream<PR_ST_2>::CLI_Stream (ACE_Thread_Manager *thr_mgr) + : inherited (thr_mgr) +{ +} + +template <PR_ST_1> int +CLI_Stream<PR_ST_2>::close (u_long) +{ + ACE_DEBUG ((LM_DEBUG, "(%t) client stream object closing down\n")); + this->peer ().close (); + + /* Must be allocated dynamically! */ + delete this; + return 0; +} + +template <PR_ST_1> int +CLI_Stream<PR_ST_2>::open (void *) +{ + ACE_INET_Addr sa; + + ACE_DEBUG ((LM_DEBUG, "(%t) client handle = %d\n", + this->peer ().get_handle ())); + + if (this->peer ().get_remote_addr (sa) == -1) + return -1; + + ACE_DEBUG ((LM_DEBUG, "(%t) accepted at port %d\n", + sa.get_port_number ())); + return 0; +} + +template <PR_ST_1> int +CLI_Stream<PR_ST_2>::svc (void) +{ + char buf[BUFSIZ]; + char login_name[L_cuserid]; + int bytes; + + ACE_OS::puts ("----------------------------------------"); + + while ((bytes = this->peer ().recv (buf, sizeof buf)) > 0) + ACE_OS::write (ACE_STDOUT, buf, bytes); + + ACE_OS::puts ("----------------------------------------"); + ACE_OS::fflush (stdout); + + long t = ACE_OS::time (0L); + ACE_OS::cuserid (login_name); + ACE_OS::sprintf (buf, "user %s %s", login_name, ACE_OS::ctime (&t)); + + if (this->peer ().send_n (buf, ACE_OS::strlen (buf) + 1) == -1) + return -1; + + ACE_DEBUG ((LM_DEBUG, "(%t) sent reply %s", buf)); + return 0; +} + +#undef SH +#undef PR_AC_1 +#undef PR_AC_2 +#undef PR_ST_1 +#undef PR_ST_2 + +//---------------------------------------- + +#if defined (ACE_HAS_TLI) +#include "ace/TLI_Stream.h" +#include "ace/TLI_Acceptor.h" +#define THR_STREAM ACE_TLI_STREAM +#define THR_ACCEPTOR ACE_TLI_ACCEPTOR +#else +#include "ace/SOCK_Stream.h" +#include "ace/SOCK_Acceptor.h" +#define THR_STREAM ACE_SOCK_STREAM +#define THR_ACCEPTOR ACE_SOCK_ACCEPTOR +#endif /* ACE_HAS_TLI */ +#include "ace/INET_Addr.h" + +typedef CLI_Stream <THR_STREAM> CLI_STREAM; +typedef Handle_Thr_Stream<CLI_STREAM, THR_ACCEPTOR> HANDLE_THR_STREAM; + +/* Static class variables */ + +u_short HANDLE_THR_STREAM::DEFAULT_PORT_ = ACE_DEFAULT_THR_PORT; + +/* Service object */ +HANDLE_THR_STREAM remote_thr_stream; +ACE_Service_Object_Type rts (&remote_thr_stream, "Remote_Thr_Stream"); + +#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +template class CLI_Stream<THR_STREAM>; +template class Handle_Thr_Stream<CLI_Stream<THR_STREAM>, THR_ACCEPTOR>; +#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ + +#endif /* ACE_HAS_THREADS */ +#endif /* ACE_HANDLE_THR_STREAM_C */ diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.h b/examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.h new file mode 100644 index 00000000000..9068fd1105d --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.h @@ -0,0 +1,76 @@ +/* -*- C++ -*- */ +// @(#)Handle_Thr_Stream.h 1.1 10/18/96 + +/* Handle connections from remote INET connections. */ + +#if !defined (_HANDLE_THR_STREAM_H) +#define _HANDLE_THR_STREAM_H + +#include "ace/Acceptor.h" +#include "ace/Service_Record.h" + +#if defined (ACE_HAS_THREADS) + +template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> +class Handle_Thr_Stream : public ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2> +{ +public: + // = Initialization and termination. + Handle_Thr_Stream (void); + ~Handle_Thr_Stream (void); + + // = Dynamic linking hooks. + virtual int init (int argc, char *argv[]); + virtual int info (char **, size_t) const; + virtual int fini (void); + +private: + typedef Handle_Thr_Stream<SVC_HANDLER, ACE_PEER_ACCEPTOR_2> inherited; + + static u_short DEFAULT_PORT_; + + ACE_Thread_Manager thr_mgr_; + // Thread manager. + + ACE_Thread_Strategy<SVC_HANDLER> thr_strategy_; + // Threading strategy. + + int thr_flags_; + // Threading flags. +}; + +// This class interacts with the client, running in a separate +// thread... +template <ACE_PEER_STREAM_1> +class CLI_Stream : public ACE_Svc_Handler<ACE_PEER_STREAM_2, ACE_MT_SYNCH> +{ +public: + CLI_Stream (ACE_Thread_Manager * = 0); + + virtual int open (void *); + // Open the service. + + virtual int close (u_long); + // Close down the service. + + virtual int svc (void); + // Execute the service. + +protected: + typedef ACE_Svc_Handler<ACE_PEER_STREAM_2, ACE_MT_SYNCH> inherited; +}; + +extern ACE_Service_Object_Type rts; + +#if defined (__ACE_INLINE__) +#define ACE_INLINE inline +#include "Handle_Thr_Stream.i" +#else +#define ACE_INLINE +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Handle_Thr_Stream.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ +#endif /* ACE_HAS_THREADS */ +#endif /* _HANDLE_THR_STREAM_H */ diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.i b/examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.i new file mode 100644 index 00000000000..5f43e47c7ec --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.i @@ -0,0 +1 @@ +/* -*- C++ -*- */ diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.cpp b/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.cpp new file mode 100644 index 00000000000..bfb562185e6 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.cpp @@ -0,0 +1,34 @@ +#include "Handle_Timeout.h" +// @(#)Handle_Timeout.cpp 1.1 10/18/96 + + +#if defined (SunOS4) +extern "C" +{ + int init (void); + int fini (void); + void __sti__Handle_Timeout_C_init_(); + void __std__Handle_Timeout_C_init_(); +} + +int +init (void) +{ + __sti__Handle_Timeout_C_init_(); + return 0; +} + +int +fini (void) +{ + __std__Handle_Timeout_C_init_(); + return 0; +} +#endif /* SunOS4 */ + +#if !defined (__ACE_INLINE__) +#include "Handle_Timeout.i" +#endif /* __ACE_INLINE__ */ + +Handle_Timeout timer_1; +ACE_Service_Object_Type t1 (&timer_1, "Timer_1"); diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.h b/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.h new file mode 100644 index 00000000000..efcb7575dad --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.h @@ -0,0 +1,36 @@ +/* -*- C++ -*- */ +// @(#)Handle_Timeout.h 1.1 10/18/96 + +/* Handles timeouts. */ + +#if !defined (_HANDLE_TIMEOUT_H) +#define _HANDLE_TIMEOUT_H + +#include "ace/Service_Config.h" +#include "ace/Service_Record.h" + +class Handle_Timeout : public ACE_Service_Object +{ +public: + Handle_Timeout (void); + virtual int init (int argc, char *argv[]); + virtual int info (char **, size_t) const; + virtual int fini (void); + +private: + virtual int get_handle (void) const; + virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg); + + int count; +}; + +extern ACE_Service_Object_Type t1; + +#if defined (__ACE_INLINE__) +#define ACE_INLINE inline +#include "Handle_Timeout.i" +#else +#define ACE_INLINE +#endif /* __ACE_INLINE__ */ + +#endif /* _HANDLE_TIMEOUT_H */ diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.i b/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.i new file mode 100644 index 00000000000..623efaf9437 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.i @@ -0,0 +1,74 @@ +/* -*- C++ -*- */ +// @(#)Handle_Timeout.i 1.1 10/18/96 + + +#include "ace/Service_Config.h" +#include "ace/Get_Opt.h" + +ACE_INLINE +Handle_Timeout::Handle_Timeout (void): count (0) +{ +} + +ACE_INLINE int +Handle_Timeout::info (char **strp, size_t length) const +{ + char buf[BUFSIZ]; + + ACE_OS::sprintf (buf, "%s", "# tests timeout facility\n"); + + if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) + return -1; + else + ACE_OS::strncpy (*strp, buf, length); + return ACE_OS::strlen (buf); +} + +ACE_INLINE int +Handle_Timeout::init (int argc, char *argv[]) +{ + ACE_Time_Value delta (10); + ACE_Time_Value interval (1); + ACE_Get_Opt get_opt (argc, argv, "a:d:i:", 0); + int arg = 0; + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'd': + delta.sec (ACE_OS::atoi (get_opt.optarg)); + break; + case 'i': + interval.sec (ACE_OS::atoi (get_opt.optarg)); + break; + case 'a': + arg = atoi (get_opt.optarg); + break; + default: + break; + } + + return ACE_Service_Config::reactor ()->schedule_timer (this, (void *) arg, delta, interval); +} + +ACE_INLINE int +Handle_Timeout::fini (void) +{ + return 0; +} + +ACE_INLINE int +Handle_Timeout::get_handle (void) const +{ + return -1; +} + +ACE_INLINE int +Handle_Timeout::handle_timeout (const ACE_Time_Value &tv, const void *arg) +{ + if (this->count++ >= 10) + return -1; /* Automatically cancel periodic timer... */ + ACE_DEBUG ((LM_INFO, "time for this(%u) expired at (%d, %d) with arg = %d\n", + this, tv.sec (), tv.usec (), int (arg))); + return 0; +} diff --git a/examples/Service_Configurator/IPC-tests/server/Makefile b/examples/Service_Configurator/IPC-tests/server/Makefile new file mode 100644 index 00000000000..3f5a97aabb3 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/Makefile @@ -0,0 +1,1016 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the server-side of the primary Reactor tests +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = server_test +LIB = libServer.a +SHLIB = libServer.so + +FILES = Handle_L_Dgram \ + Handle_L_CODgram \ + Handle_L_FIFO \ + Handle_L_Pipe \ + Handle_L_Stream \ + Handle_R_Dgram \ + Handle_R_Stream \ + Handle_Timeout \ + Handle_Broadcast \ + Handle_L_SPIPE \ + Handle_Thr_Stream + +SRC = $(addsuffix .cpp,$(BIN)) +OBJ = $(SRC:%.cpp=$(VDIR)%.o) + +LSRC = $(addsuffix .cpp,$(FILES)) +LIBS = -lACE + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VLIB) $(VSHLIB) $(SHLIBA) $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.lib.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +LDFLAGS += -L./ + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/Handle_L_Dgram.o .shobj/Handle_L_Dgram.so: Handle_L_Dgram.cpp Handle_L_Dgram.h \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Service_Record.h \ + $(WRAPPER_ROOT)/ace/Stream.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Stream.cpp \ + $(WRAPPER_ROOT)/ace/Stream.i \ + $(WRAPPER_ROOT)/ace/LSOCK_Dgram.h \ + $(WRAPPER_ROOT)/ace/SOCK_Dgram.h \ + $(WRAPPER_ROOT)/ace/SOCK_Dgram.i \ + $(WRAPPER_ROOT)/ace/LSOCK.h \ + $(WRAPPER_ROOT)/ace/LSOCK.i \ + $(WRAPPER_ROOT)/ace/LSOCK_Dgram.i \ + $(WRAPPER_ROOT)/ace/UNIX_Addr.h \ + Handle_L_Dgram.i \ + $(WRAPPER_ROOT)/ace/Get_Opt.h +.obj/Handle_L_CODgram.o .shobj/Handle_L_CODgram.so: Handle_L_CODgram.cpp Handle_L_CODgram.h \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Service_Record.h \ + $(WRAPPER_ROOT)/ace/Stream.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Stream.cpp \ + $(WRAPPER_ROOT)/ace/Stream.i \ + $(WRAPPER_ROOT)/ace/LSOCK_CODgram.h \ + $(WRAPPER_ROOT)/ace/LSOCK.h \ + $(WRAPPER_ROOT)/ace/LSOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_CODgram.h \ + $(WRAPPER_ROOT)/ace/SOCK_CODgram.i \ + $(WRAPPER_ROOT)/ace/LSOCK_CODgram.i \ + $(WRAPPER_ROOT)/ace/UNIX_Addr.h \ + Handle_L_CODgram.i \ + $(WRAPPER_ROOT)/ace/Get_Opt.h +.obj/Handle_L_FIFO.o .shobj/Handle_L_FIFO.so: Handle_L_FIFO.cpp Handle_L_FIFO.h \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Service_Record.h \ + $(WRAPPER_ROOT)/ace/Stream.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Stream.cpp \ + $(WRAPPER_ROOT)/ace/Stream.i \ + $(WRAPPER_ROOT)/ace/FIFO_Recv_Msg.h \ + $(WRAPPER_ROOT)/ace/FIFO_Recv.h \ + $(WRAPPER_ROOT)/ace/FIFO.h \ + $(WRAPPER_ROOT)/ace/FIFO_Recv.i \ + $(WRAPPER_ROOT)/ace/FIFO_Recv_Msg.i \ + Handle_L_FIFO.i \ + $(WRAPPER_ROOT)/ace/Get_Opt.h +.obj/Handle_L_Pipe.o .shobj/Handle_L_Pipe.so: Handle_L_Pipe.cpp Handle_L_Pipe.h \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Service_Record.h \ + $(WRAPPER_ROOT)/ace/Stream.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Stream.cpp \ + $(WRAPPER_ROOT)/ace/Stream.i \ + $(WRAPPER_ROOT)/ace/UNIX_Addr.h \ + $(WRAPPER_ROOT)/ace/LSOCK_Acceptor.h \ + $(WRAPPER_ROOT)/ace/SOCK_Acceptor.h \ + $(WRAPPER_ROOT)/ace/LSOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/LSOCK.h \ + $(WRAPPER_ROOT)/ace/LSOCK.i \ + $(WRAPPER_ROOT)/ace/LSOCK_Stream.i \ + Handle_L_Pipe.i \ + $(WRAPPER_ROOT)/ace/Get_Opt.h +.obj/Handle_L_Stream.o .shobj/Handle_L_Stream.so: Handle_L_Stream.cpp Handle_L_Stream.h \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Service_Record.h \ + $(WRAPPER_ROOT)/ace/Stream.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Stream.cpp \ + $(WRAPPER_ROOT)/ace/Stream.i \ + $(WRAPPER_ROOT)/ace/UNIX_Addr.h \ + $(WRAPPER_ROOT)/ace/LSOCK_Acceptor.h \ + $(WRAPPER_ROOT)/ace/SOCK_Acceptor.h \ + $(WRAPPER_ROOT)/ace/LSOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/LSOCK.h \ + $(WRAPPER_ROOT)/ace/LSOCK.i \ + $(WRAPPER_ROOT)/ace/LSOCK_Stream.i \ + Handle_L_Stream.i \ + $(WRAPPER_ROOT)/ace/Get_Opt.h +.obj/Handle_R_Dgram.o .shobj/Handle_R_Dgram.so: Handle_R_Dgram.cpp Handle_R_Dgram.h \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Service_Record.h \ + $(WRAPPER_ROOT)/ace/Stream.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Stream.cpp \ + $(WRAPPER_ROOT)/ace/Stream.i \ + $(WRAPPER_ROOT)/ace/SOCK_Dgram.h \ + $(WRAPPER_ROOT)/ace/SOCK_Dgram.i \ + Handle_R_Dgram.i \ + $(WRAPPER_ROOT)/ace/Get_Opt.h +.obj/Handle_R_Stream.o .shobj/Handle_R_Stream.so: Handle_R_Stream.cpp Handle_R_Stream.h \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Service_Record.h \ + $(WRAPPER_ROOT)/ace/Stream.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Stream.cpp \ + $(WRAPPER_ROOT)/ace/Stream.i \ + $(WRAPPER_ROOT)/ace/SOCK_Acceptor.h \ + Handle_R_Stream.i \ + $(WRAPPER_ROOT)/ace/Get_Opt.h +.obj/Handle_Timeout.o .shobj/Handle_Timeout.so: Handle_Timeout.cpp Handle_Timeout.h \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Service_Record.h \ + $(WRAPPER_ROOT)/ace/Stream.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Stream.cpp \ + $(WRAPPER_ROOT)/ace/Stream.i \ + Handle_Timeout.i \ + $(WRAPPER_ROOT)/ace/Get_Opt.h +.obj/Handle_Broadcast.o .shobj/Handle_Broadcast.so: Handle_Broadcast.cpp Handle_Broadcast.h \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Service_Record.h \ + $(WRAPPER_ROOT)/ace/Stream.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Stream.cpp \ + $(WRAPPER_ROOT)/ace/Stream.i \ + $(WRAPPER_ROOT)/ace/SOCK_Dgram.h \ + $(WRAPPER_ROOT)/ace/SOCK_Dgram.i \ + Handle_Broadcast.i \ + $(WRAPPER_ROOT)/ace/Get_Opt.h +.obj/Handle_L_SPIPE.o .shobj/Handle_L_SPIPE.so: Handle_L_SPIPE.cpp Handle_L_SPIPE.h \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Service_Record.h \ + $(WRAPPER_ROOT)/ace/Stream.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Stream.cpp \ + $(WRAPPER_ROOT)/ace/Stream.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Acceptor.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.h \ + $(WRAPPER_ROOT)/ace/SPIPE.h \ + $(WRAPPER_ROOT)/ace/SPIPE_Addr.h \ + $(WRAPPER_ROOT)/ace/SPIPE.i \ + $(WRAPPER_ROOT)/ace/SPIPE_Stream.i \ + Handle_L_SPIPE.i \ + $(WRAPPER_ROOT)/ace/Get_Opt.h +.obj/Handle_Thr_Stream.o .shobj/Handle_Thr_Stream.so: Handle_Thr_Stream.cpp \ + $(WRAPPER_ROOT)/ace/Get_Opt.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + Handle_Thr_Stream.h \ + $(WRAPPER_ROOT)/ace/Acceptor.h \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch_Options.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Svc_Handler.cpp \ + $(WRAPPER_ROOT)/ace/Dynamic.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.i \ + $(WRAPPER_ROOT)/ace/Strategies.h \ + $(WRAPPER_ROOT)/ace/Strategies.cpp \ + $(WRAPPER_ROOT)/ace/Acceptor.i \ + $(WRAPPER_ROOT)/ace/Acceptor.cpp \ + $(WRAPPER_ROOT)/ace/Service_Record.h \ + $(WRAPPER_ROOT)/ace/Stream.h \ + $(WRAPPER_ROOT)/ace/Stream.cpp \ + $(WRAPPER_ROOT)/ace/Stream.i \ + Handle_Thr_Stream.cpp Handle_Thr_Stream.i \ + $(WRAPPER_ROOT)/ace/TLI_Stream.h \ + $(WRAPPER_ROOT)/ace/TLI.h \ + $(WRAPPER_ROOT)/ace/TLI.i \ + $(WRAPPER_ROOT)/ace/TLI_Stream.i \ + $(WRAPPER_ROOT)/ace/TLI_Acceptor.h \ + $(WRAPPER_ROOT)/ace/TLI_Acceptor.i +.obj/server_test.o .shobj/server_test.so: server_test.cpp \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/Service_Configurator/IPC-tests/server/server_test.cpp b/examples/Service_Configurator/IPC-tests/server/server_test.cpp new file mode 100644 index 00000000000..3c93ca704f9 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/server_test.cpp @@ -0,0 +1,31 @@ +/* The main test driver for the dynamically configured server. */ +// @(#)server_test.cpp 1.1 10/18/96 + + +#include "ace/Service_Config.h" + +sig_atomic_t finished = 0; + +static void +handler (int) +{ + finished = 1; +} + +int +main (int argc, char *argv[]) +{ + ACE_Service_Config server_test; + + ACE_Sig_Action sig ((ACE_SignalHandler) handler, SIGINT); + + if (server_test.open (argc, argv) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "server_test.open"), -1); + + for (;;) + if (server_test.run_reactor_event_loop () == -1 && finished) + break; + + /* NOTREACHED */ + return 0; +} diff --git a/examples/Service_Configurator/IPC-tests/server/svc.conf b/examples/Service_Configurator/IPC-tests/server/svc.conf new file mode 100644 index 00000000000..47092c3d030 --- /dev/null +++ b/examples/Service_Configurator/IPC-tests/server/svc.conf @@ -0,0 +1,19 @@ +# To configure different services, simply uncomment the appropriate lines in this file! +#static ACE_Service_Manager "-d -p 3911" +dynamic Remote_Brdcast Service_Object * .shobj/Handle_Broadcast.so:remote_broadcast "-p 10001" +#dynamic Remote_Stream Service_Object * .shobj/Handle_R_Stream.so:remote_stream "-p 20002" +#dynamic Remote_Dgram Service_Object * .shobj/Handle_R_Dgram.so:remote_dgram "-p 15001" +#dynamic Timer_1 Service_Object * .shobj/Handle_Timeout.so:timer_1 "-d 5 -i 1 -a 100" +#dynamic Local_Stream Service_Object * .shobj/Handle_L_Stream.so:local_stream "-r /tmp/foo_stream" +#dynamic Local_Pipe Service_Object * .shobj/Handle_L_Pipe.so:local_pipe "-r /tmp/foo_pipe" +#dynamic Local_Fifo Service_Object * .shobj/Handle_L_FIFO.so:local_fifo "-r /tmp/foo_fifo" +#dynamic Local_Dgram Service_Object * .shobj/Handle_L_Dgram.so:local_dgram "-r /tmp/foo_dgram" +#dynamic Local_CODgram Service_Object * .shobj/Handle_L_CODgram.so:local_codgram "-r /tmp/foo_codgram" +#dynamic Local_Spipe Service_Object * .shobj/Handle_L_SPIPE.so:local_spipe "-r /tmp/foo_spipe" +#dynamic Remote_Thr_Stream Service_Object * .shobj/Handle_Thr_Stream.so:remote_thr_stream "-p 10001" +#suspend Remote_Stream +#resume Local_SPIPE +#resume Remote_Stream +#remove Remote_Stream +#remove Local_Stream + diff --git a/examples/Service_Configurator/Makefile b/examples/Service_Configurator/Makefile new file mode 100644 index 00000000000..86ad57b73ef --- /dev/null +++ b/examples/Service_Configurator/Makefile @@ -0,0 +1,22 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the Service Configurator tests +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +DIRS = IPC-tests \ + Misc + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nolocal.GNU diff --git a/examples/Service_Configurator/Misc/Makefile b/examples/Service_Configurator/Misc/Makefile new file mode 100644 index 00000000000..e9364dace7a --- /dev/null +++ b/examples/Service_Configurator/Misc/Makefile @@ -0,0 +1,105 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for a test of the miscellaneous Service_Config examples +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = main + +FILES = Timer_Service + +LSRC = $(addsuffix .cpp,$(FILES)) +LOBJ = $(addsuffix .o,$(FILES)) +SHOBJ = $(addsuffix .so,$(FILES)) + +LDLIBS = $(addprefix .shobj/,$(SHOBJ)) + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.lib.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/Timer_Service.o .shobj/Timer_Service.so: Timer_Service.cpp Timer_Service.h \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/Service_Configurator/Misc/Timer_Service.cpp b/examples/Service_Configurator/Misc/Timer_Service.cpp new file mode 100644 index 00000000000..8c377da53f5 --- /dev/null +++ b/examples/Service_Configurator/Misc/Timer_Service.cpp @@ -0,0 +1,40 @@ +#include "Timer_Service.h" +// @(#)Timer_Service.cpp 1.1 10/18/96 + + +int +Timer_Service::init (int argc, char *argv[]) +{ + char *prog = argc > 0 ? argv[0] : "Timer_Service"; + int interval = argc > 1 ? ACE_OS::atoi (argv[1]) : 4; + if (argc > 2) + ACE_Trace::start_tracing (); + else + ACE_Trace::stop_tracing (); + + ACE_DEBUG ((LM_DEBUG, "in Timer_Service::init, argv[0] = %s, argc == %d\n", + argv[0], argc)); + + + ACE_Service_Config::reactor ()->schedule_timer + (this, 0, ACE_Time_Value (1), ACE_Time_Value (interval)); + return 0; +} + +int +Timer_Service::handle_timeout (const ACE_Time_Value &tv, + const void *) +{ + ACE_DEBUG ((LM_DEBUG, "in Timer_Service::handle_timeout sec = %d, usec = %d\n", + tv.sec (), tv.usec ())); + return 0; +} + +// Define the factory function. +ACE_SVC_FACTORY_DEFINE (Timer_Service) + +// Define the object that describes the service. +ACE_STATIC_SVC_DEFINE (Timer_Service, + "Timer_Service", ACE_SVC_OBJ_T, &ACE_SVC_NAME (Timer_Service), + ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ, 0) + diff --git a/examples/Service_Configurator/Misc/Timer_Service.h b/examples/Service_Configurator/Misc/Timer_Service.h new file mode 100644 index 00000000000..b002cd6fddb --- /dev/null +++ b/examples/Service_Configurator/Misc/Timer_Service.h @@ -0,0 +1,16 @@ +/* -*- C++ -*- */ +// @(#)Timer_Service.h 1.1 10/18/96 + +#include "ace/Service_Config.h" + +class Timer_Service : public ACE_Service_Object +{ +public: + virtual int init (int argc, char *argv[]); + + virtual int handle_timeout (const ACE_Time_Value &, + const void *); +}; + +ACE_STATIC_SVC_DECLARE (Timer_Service) + diff --git a/examples/Service_Configurator/Misc/main.cpp b/examples/Service_Configurator/Misc/main.cpp new file mode 100644 index 00000000000..945465bf2ef --- /dev/null +++ b/examples/Service_Configurator/Misc/main.cpp @@ -0,0 +1,24 @@ +#include "ace/Service_Config.h" +// @(#)main.cpp 1.1 10/18/96 + +#include "Timer_Service.h" + +// Create an object that will insert the Timer_Service into the list +// of statically linked services that the ACE_Service_Config will +// process at run-time. +ACE_STATIC_SVC_REQUIRE(Timer_Service) + +int +main (int argc, char *argv[]) +{ + ACE_Service_Config daemon; + + if (daemon.open (argc, argv) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), 1); + + // Run forever, performing the configured services until we receive + // a SIGINT. + + daemon.run_reactor_event_loop (); + return 0; +} diff --git a/examples/Service_Configurator/Misc/svc.conf b/examples/Service_Configurator/Misc/svc.conf new file mode 100644 index 00000000000..c3eb2fc6cea --- /dev/null +++ b/examples/Service_Configurator/Misc/svc.conf @@ -0,0 +1 @@ +static Timer_Service "timer $TIME $TRACE" diff --git a/examples/Shared_Malloc/Makefile b/examples/Shared_Malloc/Makefile new file mode 100644 index 00000000000..002d0d7f06d --- /dev/null +++ b/examples/Shared_Malloc/Makefile @@ -0,0 +1,96 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for tests of the Shared_Malloc wrappers +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = test_malloc \ + test_persistence + +FILES = Malloc \ + Options + +LSRC = $(addsuffix .cpp,$(FILES)) +LOBJ = $(addsuffix .o,$(FILES)) +SHOBJ = $(addsuffix .so,$(FILES)) + +LDLIBS = $(addprefix .shobj/,$(SHOBJ)) + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.lib.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/Malloc.o .shobj/Malloc.so: Malloc.cpp Options.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Mem_Map.h +.obj/Options.o .shobj/Options.so: Options.cpp \ + $(WRAPPER_ROOT)/ace/Get_Opt.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + Options.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/Shared_Malloc/Malloc.cpp b/examples/Shared_Malloc/Malloc.cpp new file mode 100644 index 00000000000..f784e112124 --- /dev/null +++ b/examples/Shared_Malloc/Malloc.cpp @@ -0,0 +1,80 @@ +#include "Options.h" +// @(#)Malloc.cpp 1.1 10/18/96 + +#include "Malloc.h" + +// Determine the type of dynamic memory manager. +#if defined (ACE_HAS_THREADS) +typedef ACE_Thread_Mutex THREAD_MUTEX; +#else +typedef ACE_Null_Mutex THREAD_MUTEX; +#endif /* ACE_HAS_THREADS */ + +// ACE_Process_Mutex will work for non-MT platforms. +typedef ACE_Process_Mutex PROCESS_MUTEX; + +class MMAP_POOL : public ACE_MMAP_Memory_Pool + // = TITLE + // This class is an "adapter" that passes certain arguments to the + // constructor of ACE_MMAP_Memory_Pool. +{ +public: + MMAP_POOL (const char *); + + static const char BACKING_STORE[]; +}; + +const char MMAP_POOL::BACKING_STORE[] = "/tmp/test_malloc"; + +MMAP_POOL::MMAP_POOL (const char *) + : ACE_MMAP_Memory_Pool (BACKING_STORE, // Name of the backing store. + 1, // Use fixed addr. + 1) // Write each page of backing store. +{ +} + +// Strategic typedefs for memory allocation. + +typedef ACE_Malloc <ACE_Local_Memory_Pool, THREAD_MUTEX> L_ALLOCATOR; + +#if !defined (ACE_WIN32) +typedef ACE_Malloc <MMAP_POOL, PROCESS_MUTEX> M_ALLOCATOR; +typedef ACE_Malloc <ACE_Shared_Memory_Pool, PROCESS_MUTEX> SP_ALLOCATOR; +typedef ACE_Malloc <ACE_Shared_Memory_Pool, THREAD_MUTEX> ST_ALLOCATOR; +typedef ACE_Malloc <ACE_Sbrk_Memory_Pool, THREAD_MUTEX> SB_ALLOCATOR; +#else +typedef ACE_Malloc <MMAP_POOL, THREAD_MUTEX> M_ALLOCATOR; +typedef ACE_Malloc <MMAP_POOL, THREAD_MUTEX> SP_ALLOCATOR; +typedef ACE_Malloc <MMAP_POOL, THREAD_MUTEX> ST_ALLOCATOR; +typedef ACE_Malloc <ACE_Local_Memory_Pool, THREAD_MUTEX> SB_ALLOCATOR; +#endif /* ACE_WIN32 */ + +// Singleton +ACE_Allocator *Malloc::instance_ = 0; + +// This is a factory that decides what type of allocator to create. + +ACE_Allocator * +Malloc::instance (void) +{ + if (Malloc::instance_ == 0) + { + if (Options::instance ()->child ()) + Malloc::instance_ = new ACE_Allocator_Adapter<M_ALLOCATOR>; + else if (Options::instance ()->spawn_threads ()) + { + if (Options::instance ()->use_sbrk ()) + Malloc::instance_ = new ACE_Allocator_Adapter<SB_ALLOCATOR>; + else if (Options::instance ()->use_shmem ()) + Malloc::instance_ = new ACE_Allocator_Adapter<ST_ALLOCATOR>; + else + Malloc::instance_ = new ACE_Allocator_Adapter<L_ALLOCATOR>; + } + else if (Options::instance ()->use_mmap ()) + Malloc::instance_ = new ACE_Allocator_Adapter<M_ALLOCATOR>; + else // Use Shared_Memory_Pool. + Malloc::instance_ = new ACE_Allocator_Adapter<SP_ALLOCATOR>; + } + + return Malloc::instance_; +} diff --git a/examples/Shared_Malloc/Malloc.h b/examples/Shared_Malloc/Malloc.h new file mode 100644 index 00000000000..b3f9d5fd516 --- /dev/null +++ b/examples/Shared_Malloc/Malloc.h @@ -0,0 +1,25 @@ +/* -*- C++ -*- */ +// @(#)Malloc.h 1.1 10/18/96 + +#if !defined (MY_MALLOC_H) +#define MY_MALLOC_H + +#include "ace/Malloc.h" + +class Malloc + // = TITLE + // Allocator Singleton. +{ +public: + static ACE_Allocator *instance (void); + // Returns static instance. + +private: + Malloc (void); + // Ensure Singleton. + + static ACE_Allocator *instance_; + // Malloc Singleton. +}; + +#endif /* MY_MALLOC_H */ diff --git a/examples/Shared_Malloc/Options.cpp b/examples/Shared_Malloc/Options.cpp new file mode 100644 index 00000000000..6a9467356a3 --- /dev/null +++ b/examples/Shared_Malloc/Options.cpp @@ -0,0 +1,186 @@ +#include "ace/Get_Opt.h" +// @(#)Options.cpp 1.1 10/18/96 + +#include "ace/Log_Msg.h" +#include "Options.h" + +// Static Singleton instance. +Options *Options::instance_ = 0; + +Options * +Options::instance (void) +{ + if (Options::instance_ == 0) + Options::instance_ = new Options (); + + return Options::instance_; +} + +char * +Options::program_name (void) +{ + return this->program_name_; +} + +const char * +Options::slave_name (void) +{ + return this->slave_name_; +} + +int +Options::debug (void) +{ + return this->debug_; +} + +int +Options::exec_slave (void) +{ + return this->exec_slave_; +} + +size_t +Options::iteration_count (void) +{ + return this->iteration_count_; +} + +int +Options::use_sbrk (void) +{ + return this->use_sbrk_; +} + +size_t +Options::max_msg_size (void) +{ + return this->max_msg_size_; +} + +size_t +Options::spawn_count (void) +{ + return this->spawn_count_; +} + +int +Options::spawn_threads (void) +{ + return this->spawn_threads_; +} + +int +Options::use_mmap (void) +{ + return this->use_mmap_; +} + +int +Options::use_shmem (void) +{ + return this->use_shmem_; +} + +int +Options::child (void) +{ + return this->child_; +} + +// Explain usage and exit. + +void +Options::print_usage_and_die (void) +{ + ACE_ERROR ((LM_ERROR, "usage: %n" + "\n[-d] (run in debugging mode)\n" + "[-e] (use exec(2) in addition to fork(2))\n" + "[-l] (use C++ new operator rather than sbrk(2)\n" + "[-L max_msg_size]\n" + "[-m] (use mmap rather than SysV shared memory)\n" + "[-p] (use processes rather than threads)\n" + "[-s] (use SysV shared memory rather than mmap)\n" + "[-t number of threads or processes to spawn]\n" + "[-n iteration_count]\n%a", -1)); + /* NOTREACHED */ +} + +Options::Options (void) + : slave_name_ ("slave"), + debug_ (0), + exec_slave_ (0), + iteration_count_ (100), + use_sbrk_ (0), + use_shmem_ (0), + max_msg_size_ (127), + spawn_count_ (1), + spawn_threads_ (1), + use_mmap_ (0), + child_ (0) +{ +} + +void +Options::parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opt (argc, argv, "dehlL:mn:pst:"); + + this->program_name_ = argv[0]; + ACE_LOG_MSG->open (this->program_name_); + + // Put in a special-case check for child process. + if (ACE_OS::strcmp (this->program_name_, slave_name_) == 0) + { + this->child_ = 1; + this->use_mmap_ = 1; + } + + int c; + + while ((c = get_opt ()) != -1) + { + switch (c) + { + case 'd': + this->debug_ = 1; + break; + case 'e': + this->exec_slave_ = 1; + break; + case 'h': + this->print_usage_and_die (); + /* NOTREACHED */ + break; + case 'l': + this->use_sbrk_ = 0; + break; + case 'L': + this->max_msg_size_ = ACE_OS::atoi (get_opt.optarg); + break; + case 'm': + this->use_mmap_ = 1; + break; + case 'n': + this->iteration_count_ = ACE_OS::atoi (get_opt.optarg); + break; + case 'p': // Spawn processes rather than threads + this->spawn_threads_ = 0; + break; + case 's': + // Use System V shared memory... + this->use_shmem_ = 1; + break; + case 't': + this->spawn_count_ = ACE_OS::atoi (get_opt.optarg); + break; + default: + this->print_usage_and_die (); + /* NOTREACHED */ + break; + } + } + // Switch to using MMAP when the -p and -e options are enabled. + if (this->exec_slave_ == 1 && this->spawn_threads_ == 0) + this->use_mmap_ = 1; +} diff --git a/examples/Shared_Malloc/Options.h b/examples/Shared_Malloc/Options.h new file mode 100644 index 00000000000..769e1a4db13 --- /dev/null +++ b/examples/Shared_Malloc/Options.h @@ -0,0 +1,81 @@ +/* -*- C++ -*- */ +// @(#)Options.h 1.1 10/18/96 + +#if !defined (_OPTIONS) +#define _OPTIONS + +#include "ace/OS.h" + +class Options + // = TITLE + // Options Singleton. +{ +public: + static Options *instance (void); + // Return Singleton. + + void parse_args (int argc, char *argv[]); + // Parse the arguments. + + // = Accessor methods. + char *program_name (void); + const char *slave_name (void); + int debug (void); + int exec_slave (void); + size_t iteration_count (void); + int use_sbrk (void); + int use_shmem (void); + size_t max_msg_size (void); + size_t spawn_count (void); + int spawn_threads (void); + int use_mmap (void); + int child (void); + +private: + Options (void); + // Ensure Singleton. + + static Options *instance_; + // Singleton. + + void print_usage_and_die (void); + // Explain usage and exit. + + char *program_name_; + // Name of the program. + + const char *slave_name_; + // Name of slave process. + + int debug_; + // Flag to indicate if we are debugging. + + int exec_slave_; + // Flag to indicate if we should exec after forking. + + size_t iteration_count_; + // Number of iterations to call malloc_recurse(). + + int use_sbrk_; + // Should we use sbrk(2)? + + int use_shmem_; + // Should we use Shared Memory? + + size_t max_msg_size_; + // Maximum number of bytes to malloc. + + size_t spawn_count_; + // Number of threads. + + int spawn_threads_; + // Spawn threads vs. processes. + + int use_mmap_; + // Use mmap() as the backing store. + + int child_; + // We're a child process. +}; + +#endif /* _OPTIONS */ diff --git a/examples/Shared_Malloc/test_malloc.cpp b/examples/Shared_Malloc/test_malloc.cpp new file mode 100644 index 00000000000..9a1d355701b --- /dev/null +++ b/examples/Shared_Malloc/test_malloc.cpp @@ -0,0 +1,195 @@ +// This program tests out all the various ACE_Malloc combinations and +// @(#)test_malloc.cpp 1.1 10/18/96 + +// the ACE_Allocator_Adapter. + +#include "ace/Thread.h" +#include "ace/Thread_Manager.h" +#include "Malloc.h" +#include "Options.h" + +// Global thread manager. +static ACE_Thread_Manager thread_manager; + +static int +gen_size (void) +{ +#if defined (ACE_HAS_THREADS) + ACE_RANDR_TYPE seed = ACE_RANDR_TYPE (&seed); + return (ACE_OS::rand_r (ACE_RANDR_TYPE (seed)) % Options::instance ()->max_msg_size ()) + 1; +#else + return (ACE_OS::rand () % Options::instance ()->max_msg_size ()) + 1; +#endif /* ACE_HAS_THREADS */ +} + +// Recursively allocate and deallocate dynamic memory. + +static int +malloc_recurse (int count) +{ + static char default_char = 0; + + if (count <= 0) + { + if (Options::instance ()->debug ()) + AMS (Malloc::instance ()->print_stats ()); + } + else + { + int alloc_size = gen_size (); + void *ptr = Malloc::instance ()->malloc (alloc_size); + + if (ptr == 0) + ACE_ERROR ((LM_ERROR, "(%P|%t) *** malloc of size %d failed, %p\n%a", + "malloc", alloc_size)); + else + { + ACE_OS::memset (ptr, default_char++, alloc_size); + + if (Options::instance ()->debug ()) + ACE_DEBUG ((LM_INFO, "(%P|%t) %u (alloc), size = %d\n", ptr, alloc_size)); + + // Call ourselves recursively + malloc_recurse (count - 1); + + if (Options::instance ()->debug ()) + ACE_DEBUG ((LM_INFO, "(%P|%t) %u (free), size = %d\n", ptr, alloc_size)); + + Malloc::instance ()->free (ptr); + } + } + return 0; +} + +static void * +worker (void *arg) +{ + // Allocate a thread control object, which automatically removes the + // thread from the thread manager on exit. + ACE_Thread_Control tc (&thread_manager); + + malloc_recurse (int (arg)); + return 0; +} + +// Create the appropriate type of process/thread. + +static void +spawn (void) +{ + if (Options::instance ()->spawn_threads ()) + { +#if defined (ACE_HAS_THREADS) + if (thread_manager.spawn (ACE_THR_FUNC (worker), + (void *) Options::instance ()->iteration_count (), + THR_BOUND) == -1) + ACE_ERROR ((LM_ERROR, "%p\n%a", "thread create failed")); +#else + if (Options::instance ()->spawn_count () > 1) + ACE_ERROR ((LM_ERROR, "only one thread may be run in a process on this platform\n%a", 1)); +#endif /* ACE_HAS_THREADS */ + } +#if !defined (ACE_WIN32) + else + { + if (ACE_OS::fork () == 0) + { + if (Options::instance ()->exec_slave ()) + { + char iterations[20]; + char msg_size[20]; + + ACE_OS::sprintf (iterations, "%d", Options::instance ()->iteration_count ()); + ACE_OS::sprintf (msg_size, "%d", Options::instance ()->max_msg_size ()); + + char *argv[8]; + argv[0] = (char *) Options::instance ()->slave_name (); + argv[1] = "-p"; + argv[2] = "-n"; + argv[3] = iterations; + argv[4] = "-L"; + argv[5] = msg_size; + argv[6] = Options::instance ()->debug () ? "-d" : ""; + argv[7] = (char *) 0; + + if (ACE_OS::execv (Options::instance ()->program_name (), argv) == -1) + ACE_ERROR ((LM_ERROR, "%p\n", "exec failed")); + ACE_OS::_exit (1); + } + else + { + ACE_LOG_MSG->sync (Options::instance ()->program_name ()); + + ACE_DEBUG ((LM_INFO, + "(%P|%t) about to recurse with iteration count = %d\n", + Options::instance ()->iteration_count ())); + + malloc_recurse (Options::instance ()->iteration_count ()); + ACE_OS::exit (0); + } + } + } +#endif /* ACE_WIN32 */ +} + +// Wait for all the child processes/threads to exit. + +static void +wait_for_children (void) +{ + if (Options::instance ()->spawn_threads ()) + { +#if defined (ACE_HAS_THREADS) + // Wait for the threads to terminate. + thread_manager.wait (); +#else + malloc_recurse (Options::instance ()->iteration_count ()); +#endif /* ACE_HAS_THREADS */ + } +#if !defined (ACE_WIN32) + else + { + pid_t pid; + + while ((pid = ACE_OS::wait (0)) != -1) + ACE_DEBUG ((LM_DEBUG, "(%P|%t) reaped pid = %d\n", pid)); + } +#endif /* ACE_WIN32 */ +} + +static void +handler (int) +{ + Malloc::instance ()->remove (); + ACE_ERROR ((LM_ERROR, "(%P|%t) removed handler\n%a", 0)); +} + +int +main (int argc, char *argv[]) +{ + signal (SIGINT, ACE_SignalHandler (handler)); + + Options::instance ()->parse_args (argc, argv); + +#if !defined (ACE_WIN32) + if (Options::instance ()->child ()) + { + ACE_DEBUG ((LM_INFO, + "(%P|%t) about to recurse with iteration count = %d, debug = %d\n", + Options::instance ()->iteration_count ())); + + // We've been forked... + malloc_recurse (Options::instance ()->iteration_count ()); + } + else +#endif /* ACE_WIN32 */ + { + for (size_t i = 0; i < Options::instance ()->spawn_count (); i++) + spawn (); + + wait_for_children (); + Malloc::instance ()->remove (); + } + return 0; +} + diff --git a/examples/Shared_Malloc/test_persistence.cpp b/examples/Shared_Malloc/test_persistence.cpp new file mode 100644 index 00000000000..8f499a6a01d --- /dev/null +++ b/examples/Shared_Malloc/test_persistence.cpp @@ -0,0 +1,246 @@ +// Test the persistence capabilities of the ACE shared memory manager. +// @(#)test_persistence.cpp 1.1 10/18/96 + + +#include "ace/Log_Msg.h" +#include "ace/Malloc.h" + +typedef ACE_Malloc <ACE_MMAP_Memory_Pool, ACE_Null_Mutex> MALLOC; +typedef ACE_Malloc_Iterator <ACE_MMAP_Memory_Pool, ACE_Null_Mutex> MALLOC_ITERATOR; + +// Shared memory manager. +static MALLOC *shmem_manager = 0; + +// Backing store name. +static char *backing_store = ACE_DEFAULT_BACKING_STORE; + +class Employee +{ +public: + Employee (void): name_ (0), id_ (0) {} + + Employee (char* name, u_long id) : id_ (id) + { + this->name_ = (char*) shmem_manager->malloc (ACE_OS::strlen (name) + 1); + ACE_OS::strcpy (this->name_, name ); + } + + ~Employee (void) { shmem_manager->free (this->name_); } + + char *name (void) const { return this->name_; } + + void name (char* name) + { + if (this->name_) + shmem_manager->free (this->name_); + this->name_ = (char*) shmem_manager->malloc (ACE_OS::strlen (name) + 1); + ACE_OS::strcpy (this->name_, name); + } + + u_long id (void) const { return id_; } + + void id (u_long id) { id_ = id; } + + friend ostream &operator<<(ostream &stream, const Employee &employee) + { + stream << endl; + stream << "Employee name: " << employee.name() << endl; + stream << "Employee id: " << employee.id() << endl; + stream << endl; + + return stream; + } + + void *operator new (size_t size) + { + return shmem_manager->malloc (sizeof (Employee)); + } + + void operator delete (void *pointer) { shmem_manager->free (pointer); } + +private: + char *name_; + // Employee name. + + u_long id_; + // Employee ID. +}; + +class GUI_Handler +{ +public: + GUI_Handler (void) { menu(); } + + ~GUI_Handler (void) + { + MALLOC::MEMORY_POOL &pool = shmem_manager->memory_pool(); + pool.sync (); + } + + int service(void) + { + char option[BUFSIZ]; + char buf1[BUFSIZ]; + char buf2[BUFSIZ]; + + if (::scanf ("%s", option) <= 0) + { + ACE_ERROR ((LM_ERROR, "try again\n")); + return 0; + } + + int result = 0; + switch (option[0]) + { + case 'I' : + case 'i' : + if (::scanf ("%s %s", buf1, buf2) <= 0) + break; + result = insert_employee (buf1, ACE_OS::atoi (buf2)); + break; + case 'F' : + case 'f' : + if (::scanf ("%s", buf1) <= 0) + break; + result = find_employee (buf1); + break; + case 'D' : + case 'd' : + if (::scanf ("%s", buf1) <= 0) + break; + result = delete_employee (buf1); + break; + case 'L' : + case 'l' : + result = list_employees (); + break; + case 'Q' : + case 'q' : + return -1; + break; + default : + cout << "unrecognized command" << endl; + } + if (result == 0) + cout << "Last operation was successful!!" << endl; + else + cout << "Last operation failed!! " << endl; + + menu (); + + return 0; + } + + void menu(void) + { + cout << endl; + cout << "\t************************** " << endl; + cout << "\tThe employee database menu " << endl; + cout << endl; + cout << "\t<I> Insert <name> <id> " << endl; + cout << "\t<D> Delete <name> " << endl; + cout << "\t<F> Find <name> " << endl; + cout << endl; + cout << "\t<L> List all employees " << endl; + cout << endl; + cout << "\t<Q> Quit " << endl; + cout << "\t************************** " << endl; + } + +private: + int insert_employee (char* name, u_long id) + { + if (find_employee (name) == 0) + ACE_ERROR_RETURN ((LM_ERROR, "Employee already exists\n"), -1); + + Employee* new_employee = new Employee (name, id); + shmem_manager->bind (name, new_employee); + return 0; + } + + int find_employee (char* name) + { + void *temp; + if (shmem_manager->find (name, temp) == 0) + { + Employee *employee = (Employee *) temp; + + ACE_DEBUG ((LM_DEBUG, "The following employee was found.......\n\n")); + ACE_DEBUG ((LM_DEBUG, "Employee name: %s\nEmployee id: %d\n", + employee->name (), employee->id ())); + return 0; + } + + return -1; + } + + int list_employees (void) + { + MALLOC_ITERATOR iterator (*shmem_manager); + + ACE_DEBUG ((LM_DEBUG, "The following employees were found.......\n\n")); + + for (void* temp = 0; + iterator.next (temp) != 0; + iterator.advance ()) + { + Employee *employee = (Employee *) temp; + ACE_DEBUG ((LM_DEBUG, "Employee name: %s\nEmployee id: %d\n", + employee->name (), employee->id ())); + } + return 0; + } + + int delete_employee (char* name) + { + void *temp; + + if (shmem_manager->unbind (name, temp) == 0) + { + Employee *employee = (Employee *) temp; + + ACE_DEBUG ((LM_DEBUG, + "The following employee was found and deleted.......\n\n")); + + ACE_DEBUG ((LM_DEBUG, "Employee name: %s\nEmployee id: %d\n", + employee->name (), employee->id ())); + + delete employee; + return 0; + } + + ACE_DEBUG ((LM_DEBUG, "There is no employee with name %s", name)); + return -1; + } +}; + +void +parse_args (int argc, char *argv[]) +{ + if (argc > 1); + backing_store = argv[1]; +} + +int +main (int argc, char *argv[]) +{ + parse_args (argc, argv); + + shmem_manager = new MALLOC (backing_store); + + GUI_Handler handler; + + for(;;) + if (handler.service() == -1) + { + ACE_DEBUG ((LM_DEBUG, "closing down ....\n")); + break; + } + + return 0; +} + +#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +template class ACE_Malloc <ACE_MMAP_Memory_Pool, ACE_Null_Mutex>; +template class ACE_Malloc_Iterator <ACE_MMAP_Memory_Pool, ACE_Null_Mutex>; +#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ diff --git a/examples/Shared_Memory/Makefile b/examples/Shared_Memory/Makefile new file mode 100644 index 00000000000..d96a154ed6f --- /dev/null +++ b/examples/Shared_Memory/Makefile @@ -0,0 +1,76 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for tests of the Shared_Malloc wrappers +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = test_MM \ + test_SV + +LSRC = test_MM.cpp \ + test_SV.cpp + +LDLIBS = + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +INSTALL = + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/test_MM.o .shobj/test_MM.so: test_MM.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Shared_Memory_MM.h \ + $(WRAPPER_ROOT)/ace/Shared_Memory.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h +.obj/test_SV.o .shobj/test_SV.so: test_SV.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Shared_Memory_SV.h \ + $(WRAPPER_ROOT)/ace/Shared_Memory.h \ + $(WRAPPER_ROOT)/ace/SV_Shared_Memory.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/Shared_Memory/test_MM.cpp b/examples/Shared_Memory/test_MM.cpp new file mode 100644 index 00000000000..8cb304c8ac2 --- /dev/null +++ b/examples/Shared_Memory/test_MM.cpp @@ -0,0 +1,63 @@ +#include "ace/Log_Msg.h" +// @(#)test_MM.cpp 1.1 10/18/96 + +#include "ace/Shared_Memory_MM.h" + +#define SHMSZ 27 +char shm_key[] = "/tmp/fooXXXXXX"; + +static void +client (void) +{ + ACE_Shared_Memory *shm_client = new ACE_Shared_Memory_MM (shm_key); + char *shm = (char *) shm_client->malloc (); + + for (char *s = shm; *s != '\0'; s++) + putchar (*s); + + putchar ('\n'); + *shm = '*'; +} + +static void +server (void) +{ + ACE_Shared_Memory *shm_server = new ACE_Shared_Memory_MM (shm_key, SHMSZ); + char *shm = (char *) shm_server->malloc (); + char *s = shm; + + for (char c = 'a'; c <= 'z'; c++) + *s++ = c; + + *s = '\0'; + + // Perform a busy wait (ugh) + while (*shm != '*') + ACE_OS::sleep (1); + + if (shm_server->remove () < 0) + ACE_ERROR ((LM_ERROR, "%p\n", "remove")); + ACE_OS::unlink (shm_key); +} + +int +main (int, char *[]) +{ + if (ACE_OS::mktemp (shm_key) == 0 || (ACE_OS::unlink (shm_key) == -1 && errno == EPERM)) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", shm_key), 1); + + switch (ACE_OS::fork ()) + { + case -1: + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "fork"), 1); + case 0: + ACE_OS::sleep (1); + client (); + break; + default: + server (); + break; + } + return 0; +} + diff --git a/examples/Shared_Memory/test_SV.cpp b/examples/Shared_Memory/test_SV.cpp new file mode 100644 index 00000000000..f585318ea1a --- /dev/null +++ b/examples/Shared_Memory/test_SV.cpp @@ -0,0 +1,60 @@ +#include "ace/Log_Msg.h" +// @(#)test_SV.cpp 1.1 10/18/96 + +#include "ace/Shared_Memory_SV.h" + +#define SHMSZ 27 +#define SHM_KEY 5678 + +static void +client (void) +{ + ACE_Shared_Memory_SV shm_client (SHM_KEY, SHMSZ); + char *shm = (char *) shm_client.malloc (); + + for (char *s = shm; *s != '\0'; s++) + putchar (*s); + + putchar ('\n'); + *shm = '*'; +} + +static void +server (void) +{ + ACE_Shared_Memory_SV shm_server (SHM_KEY, SHMSZ, + ACE_Shared_Memory_SV::ACE_CREATE); + char *shm = (char *) shm_server.malloc (); + char *s = shm; + + for (char c = 'a'; c <= 'z'; c++) + *s++ = c; + + *s = '\0'; + + while (*shm != '*') + ACE_OS::sleep (1); + + if (shm_server.remove () < 0) + ACE_ERROR ((LM_ERROR, "%p\n", "remove")); +} + +int +main (int, char *[]) +{ + switch (ACE_OS::fork ()) + { + case -1: + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "fork"), 1); + case 0: + ACE_OS::sleep (1); + client (); + break; + default: + server (); + break; + } + + return 0; +} + diff --git a/examples/System_V_IPC/Makefile b/examples/System_V_IPC/Makefile new file mode 100644 index 00000000000..f799c16b5dc --- /dev/null +++ b/examples/System_V_IPC/Makefile @@ -0,0 +1,26 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the System V IPC directory +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +INFO = README + +DIRS = SV_Message_Queues \ + SV_Semaphores \ + SV_Shared_Memory + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nolocal.GNU + diff --git a/examples/System_V_IPC/README b/examples/System_V_IPC/README new file mode 100644 index 00000000000..c5ebde21a60 --- /dev/null +++ b/examples/System_V_IPC/README @@ -0,0 +1,13 @@ +This directory contains a number of examples that illustrate how to +use the following ACE library components: + + . SV_Message_Queues + Illustrates the ACE wrappers for System V Message + Queues. + + . SV_Semaphores + Illustrates the ACE wrappers for System V Semaphores. + + . SV_Shared_Memory + Illustrates the ACE wrappers for System V Shared Memory. + diff --git a/examples/System_V_IPC/SV_Message_Queues/MQ_Client.cpp b/examples/System_V_IPC/SV_Message_Queues/MQ_Client.cpp new file mode 100644 index 00000000000..31d56c23e6a --- /dev/null +++ b/examples/System_V_IPC/SV_Message_Queues/MQ_Client.cpp @@ -0,0 +1,29 @@ +#include "ace/SV_Message_Queue.h" +// @(#)MQ_Client.cpp 1.1 10/18/96 + +#include "test.h" + +int +main (void) +{ + long pid = long (ACE_OS::getpid ()); + ACE_SV_Message_Queue msgque (SRV_KEY); + ACE_Message_Block send_msg (SRV_ID, pid, ACE_OS::cuserid (0), "did you get this?"); + ACE_Message_Block recv_msg (pid); + + if (msgque.send (send_msg, send_msg.length ()) < 0) + ACE_OS::perror ("msgque.send"), ACE_OS::exit (1); + + if (msgque.recv (recv_msg, sizeof (Message_Data), recv_msg.type ()) < 0) + ACE_OS::perror ("msgrcv"), ACE_OS::exit (1); + + cout << "a message of length " + << recv_msg.length () + << " received from server " + << recv_msg.pid () + << " (user " + << recv_msg.user () << "): " + << recv_msg.text () << "\n"; + + return 0; +} diff --git a/examples/System_V_IPC/SV_Message_Queues/MQ_Server.cpp b/examples/System_V_IPC/SV_Message_Queues/MQ_Server.cpp new file mode 100644 index 00000000000..1f7729ad4e1 --- /dev/null +++ b/examples/System_V_IPC/SV_Message_Queues/MQ_Server.cpp @@ -0,0 +1,51 @@ +#include "ace/Signal.h" +// @(#)MQ_Server.cpp 1.1 10/18/96 + +#include "ace/SV_Message_Queue.h" +#include "test.h" + +/* Must be global for signal Message... */ +ACE_SV_Message_Queue msgque (SRV_KEY, ACE_SV_Message_Queue::ACE_CREATE); + +void +SIGNAL_handler (int) +{ + if (msgque.remove () < 0) + ACE_OS::perror ("msgque.close"), ACE_OS::exit (1); + ACE_OS::exit (0); +} + +int +main (void) +{ + long pid = long (ACE_OS::getpid ()); + ACE_Message_Block recv_msg (SRV_ID); + ACE_Message_Block send_msg (0, pid, ACE_OS::cuserid (0), + "I received your message."); + + ACE_Sig_Action sig ((ACE_SignalHandler) SIGNAL_handler, SIGINT); + + for (;;) + { + if (msgque.recv (recv_msg, sizeof (Message_Data), recv_msg.type ()) == -1) + ::perror ("msgque.recv"), ACE_OS::exit (1); + + cout << "a msg of length " + << recv_msg.length () + << " sent from client " + << recv_msg.pid () + << " (user " + << recv_msg.user () << "): " + << recv_msg.text () << "\n"; + cout.flush (); + + send_msg.type (recv_msg.pid ()); + + if (msgque.send (send_msg, send_msg.length ()) < 0) + ACE_OS::perror ("msgque.send"), ACE_OS::exit (1); + } + + /* NOTREACHED */ + return 0; +} + diff --git a/examples/System_V_IPC/SV_Message_Queues/Makefile b/examples/System_V_IPC/SV_Message_Queues/Makefile new file mode 100644 index 00000000000..cf5b28482e9 --- /dev/null +++ b/examples/System_V_IPC/SV_Message_Queues/Makefile @@ -0,0 +1,101 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for testing the typed and untyped Message Queue abstraction +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = MQ_Server \ + MQ_Client \ + TMQ_Server \ + TMQ_Client + +LSRC = $(addsuffix .cpp,$(BIN)) + +LDLIBS = + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/MQ_Server.o .shobj/MQ_Server.so: MQ_Server.cpp \ + $(WRAPPER_ROOT)/ace/SV_Message_Queue.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/SV_Message.h \ + $(WRAPPER_ROOT)/ace/SV_Message_Queue.i \ + test.h +.obj/MQ_Client.o .shobj/MQ_Client.so: MQ_Client.cpp \ + $(WRAPPER_ROOT)/ace/SV_Message_Queue.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/SV_Message.h \ + $(WRAPPER_ROOT)/ace/SV_Message_Queue.i \ + test.h +.obj/TMQ_Server.o .shobj/TMQ_Server.so: TMQ_Server.cpp \ + $(WRAPPER_ROOT)/ace/Typed_SV_Message_Queue.h \ + $(WRAPPER_ROOT)/ace/SV_Message_Queue.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/SV_Message.h \ + $(WRAPPER_ROOT)/ace/SV_Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Typed_SV_Message.h \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/Synch_T.h test.h +.obj/TMQ_Client.o .shobj/TMQ_Client.so: TMQ_Client.cpp \ + $(WRAPPER_ROOT)/ace/Typed_SV_Message_Queue.h \ + $(WRAPPER_ROOT)/ace/SV_Message_Queue.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/SV_Message.h \ + $(WRAPPER_ROOT)/ace/SV_Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Typed_SV_Message.h \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/Synch_T.h test.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/System_V_IPC/SV_Message_Queues/TMQ_Client.cpp b/examples/System_V_IPC/SV_Message_Queues/TMQ_Client.cpp new file mode 100644 index 00000000000..0961f92da6a --- /dev/null +++ b/examples/System_V_IPC/SV_Message_Queues/TMQ_Client.cpp @@ -0,0 +1,43 @@ +#include "ace/Typed_SV_Message_Queue.h" +// @(#)TMQ_Client.cpp 1.1 10/18/96 + +#include "ace/Log_Msg.h" +#include "test.h" + +int +main (void) +{ + long pid = long (ACE_OS::getpid ()); + + ACE_Typed_SV_Message_Queue<Message_Data> msgque (key_t (SRV_KEY)); + + Message_Data msg_data (pid, ACE_OS::cuserid (0), "did you get this?"); + + ACE_Typed_SV_Message<Message_Data> send_msg (msg_data, + SRV_ID, + msg_data.length ()), + recv_msg (pid); + + if (msgque.send (send_msg) < 0) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "msgque.send"), 1); + + if (msgque.recv (recv_msg) < 0) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "msgque.recv"), 1); + + Message_Data &recv_msg_data = recv_msg.data (); + + cout << "a message of length " + << recv_msg_data.length () + << " received from server " + << recv_msg_data.pid () + << " (user " + << recv_msg_data.user () << "): " + << recv_msg_data.text () << "\n"; + + return 0; +} + +#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +template class ACE_Typed_SV_Message_Queue<Message_Data>; +template class ACE_Typed_SV_Message<Message_Data>; +#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ diff --git a/examples/System_V_IPC/SV_Message_Queues/TMQ_Server.cpp b/examples/System_V_IPC/SV_Message_Queues/TMQ_Server.cpp new file mode 100644 index 00000000000..ab843c830d6 --- /dev/null +++ b/examples/System_V_IPC/SV_Message_Queues/TMQ_Server.cpp @@ -0,0 +1,59 @@ +#include "ace/Signal.h" +// @(#)TMQ_Server.cpp 1.1 10/18/96 + +#include "ace/Typed_SV_Message_Queue.h" +#include "ace/Log_Msg.h" +#include "test.h" + +// Must be global for signal Message... +ACE_Typed_SV_Message_Queue<Message_Data> msgque + (SRV_KEY, ACE_Typed_SV_Message_Queue<Message_Data>::ACE_CREATE); + +void +SIGNAL_handler (int) +{ + if (msgque.remove () < 0) + ACE_ERROR ((LM_ERROR, "%p\n%a", "msgque.recv", 1)); + ACE_OS::exit (0); +} + +int +main (void) +{ + char *username = ACE_OS::cuserid (0); + Message_Data msg_data ((int) ACE_OS::getpid (), username, "I received your message."); + ACE_Typed_SV_Message<Message_Data> send_msg (msg_data, 0, msg_data.length ()); + ACE_Typed_SV_Message<Message_Data> recv_msg (SRV_ID); + + ACE_Sig_Action sig2 ((ACE_SignalHandler) SIGNAL_handler, SIGINT); + + for (;;) + { + if (msgque.recv (recv_msg) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "msgque.recv"), 1); + + Message_Data &recv_msg_data = recv_msg.data (); + + cout << "a msg of length " + << recv_msg_data.length () + << " sent from client " + << recv_msg_data.pid () + << " (user " + << recv_msg_data.user () << "): " + << recv_msg_data.text () << "\n"; + cout.flush (); + + send_msg.type (recv_msg_data.pid ()); + + if (msgque.send (send_msg) < 0) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "msgque.send"), 1); + } + + /* NOTREACHED */ + return 0; +} + +#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +template class ACE_Typed_SV_Message_Queue<Message_Data>; +template class ACE_Typed_SV_Message<Message_Data>; +#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ diff --git a/examples/System_V_IPC/SV_Message_Queues/test.h b/examples/System_V_IPC/SV_Message_Queues/test.h new file mode 100644 index 00000000000..ebfbe3448ac --- /dev/null +++ b/examples/System_V_IPC/SV_Message_Queues/test.h @@ -0,0 +1,42 @@ +/* -*- C++ -*- */ +// @(#)test.h 1.1 10/18/96 + +#include "ace/OS.h" +#include "ace/SV_Message.h" + +#define MSGSZ 128 +#define SRV_KEY ACE_DEFAULT_SHM_KEY +#define SRV_ID 1 + +class Message_Data +{ +public: + Message_Data (long p = -1, const char user[] = "", char text[] = ""): pid_ (p) + { + ::strncpy (this->username_, user, 9); + ::strncpy (this->mtext_, text, MSGSZ); + } + + long pid (void) { return this->pid_; } + void pid (long p) { this->pid_ = p; } + char *user (void) { return this->username_; } + void user (char user[]) { ::strncpy (this->username_, user, 9); } + char *text (void) { return this->mtext_; } + void text (char text[]) { ::strncpy (this->mtext_, text, MSGSZ); } + int length (void) { return sizeof *this - sizeof this->mtext_ + ::strlen (this->mtext_) + 1; } + +protected: + long pid_; + char username_[9]; + char mtext_[MSGSZ]; +}; + +/* Note, this may not be 100 percent portable on all C++ compilers... */ +class ACE_Message_Block : public ACE_SV_Message, public Message_Data +{ +public: + ACE_Message_Block (long t, long p = 0, char login[] = "", char message[] = "") + : ACE_SV_Message (t), Message_Data (p, login, message) + {} +}; + diff --git a/examples/System_V_IPC/SV_Semaphores/Makefile b/examples/System_V_IPC/SV_Semaphores/Makefile new file mode 100644 index 00000000000..09ab2ef1359 --- /dev/null +++ b/examples/System_V_IPC/SV_Semaphores/Makefile @@ -0,0 +1,116 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for Semaphore wrapper class +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = Semaphore_Client \ + Semaphore_Server \ + Semaphores + +LSRC = $(addsuffix .cpp,$(BIN)) + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/Semaphore_Client.o .shobj/Semaphore_Client.so: Semaphore_Client.cpp Semaphore_Test.h \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/SV_Shared_Memory.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i +.obj/Semaphore_Server.o .shobj/Semaphore_Server.so: Semaphore_Server.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/SV_Shared_Memory.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + Semaphore_Test.h +.obj/Semaphores.o .shobj/Semaphores.so: Semaphores.cpp \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + Semaphore_Test.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/System_V_IPC/SV_Semaphores/Semaphore_Client.cpp b/examples/System_V_IPC/SV_Semaphores/Semaphore_Client.cpp new file mode 100644 index 00000000000..69b414cef0c --- /dev/null +++ b/examples/System_V_IPC/SV_Semaphores/Semaphore_Client.cpp @@ -0,0 +1,31 @@ +#include "Semaphore_Test.h" +// @(#)Semaphore_Client.cpp 1.1 10/18/96 + +#include "ace/SV_Shared_Memory.h" +#include "ace/SV_Semaphore_Simple.h" + +int +main (void) +{ + ACE_SV_Shared_Memory shm_client (SHM_KEY, + SHMSZ, + ACE_SV_Shared_Memory::ACE_OPEN); + ACE_SV_Semaphore_Simple sem (SEM_KEY_1, + ACE_SV_Semaphore_Simple::ACE_OPEN, 0, 2); + + char *s = (char *) shm_client.get_segment_ptr (); + + if (sem.acquire (0) < 0) + ACE_OS::perror ("client sem.acquire"), ACE_OS::exit (1); + + while (*s != '\0') + putchar (*s++); + + putchar ('\n'); + + if (sem.release (1) < 0) + ACE_OS::perror ("client sem.release"), ACE_OS::exit (1); + + return 0; +} + diff --git a/examples/System_V_IPC/SV_Semaphores/Semaphore_Server.cpp b/examples/System_V_IPC/SV_Semaphores/Semaphore_Server.cpp new file mode 100644 index 00000000000..721bb07171e --- /dev/null +++ b/examples/System_V_IPC/SV_Semaphores/Semaphore_Server.cpp @@ -0,0 +1,41 @@ +#include "ace/Log_Msg.h" +// @(#)Semaphore_Server.cpp 1.1 10/18/96 + +#include "ace/SV_Shared_Memory.h" +#include "ace/SV_Semaphore_Simple.h" +#include "ace/Signal.h" +#include "Semaphore_Test.h" + +ACE_SV_Shared_Memory shm_server (SHM_KEY, SHMSZ, ACE_SV_Shared_Memory::ACE_CREATE); +ACE_SV_Semaphore_Simple sem (SEM_KEY_1, ACE_SV_Semaphore_Simple::ACE_CREATE, 0, 2); + +static void +cleanup (int = 0) +{ + if (shm_server.remove () < 0 || sem.remove () < 0) + ACE_ERROR ((LM_ERROR, "%p\n%a", "remove", 1)); + ACE_OS::exit (0); +} + +int +main (void) +{ + ACE_Sig_Action sig ((ACE_SignalHandler) cleanup, SIGINT); + + char *s = (char *) shm_server.get_segment_ptr (); + + for (char c = 'a'; c <= 'z'; c++) + *s++ = c; + + *s = '\0'; + + if (sem.release (0) < 0) + ESD ("server sem.release", done); + + if (sem.acquire (1) < 0) + ESD ("server sem.acquire", done); + +done: + cleanup (); + return 0; +} diff --git a/examples/System_V_IPC/SV_Semaphores/Semaphore_Test.h b/examples/System_V_IPC/SV_Semaphores/Semaphore_Test.h new file mode 100644 index 00000000000..07bc3e9ecec --- /dev/null +++ b/examples/System_V_IPC/SV_Semaphores/Semaphore_Test.h @@ -0,0 +1,11 @@ +/* -*- C++ -*- */ +// @(#)Semaphore_Test.h 1.1 10/18/96 + +#include "ace/Log_Msg.h" + +#define SHMSZ 27 +#define SEM_KEY_1 2345 +#define SEM_KEY_2 4321 +#define SHM_KEY 5678 + +#define ESD(MSG,LABEL) do { ACE_ERROR ((LM_ERROR, MSG)); goto LABEL; } while (0) diff --git a/examples/System_V_IPC/SV_Semaphores/Semaphores.cpp b/examples/System_V_IPC/SV_Semaphores/Semaphores.cpp new file mode 100644 index 00000000000..923bd142cc3 --- /dev/null +++ b/examples/System_V_IPC/SV_Semaphores/Semaphores.cpp @@ -0,0 +1,94 @@ +// Illustrates the use of the Semaphore_Complex class. Note that it +// @(#)Semaphores.cpp 1.1 10/18/96 + +// doesn't matter whether the parent or the child creates the +// semaphore since Semaphore_Complex will correctly serialize the +// intialization of the mutex and synch objects. +#include "ace/Malloc.h" +#include "ace/SV_Semaphore_Complex.h" +#include "Semaphore_Test.h" + +ACE_Malloc<ACE_Shared_Memory_Pool, ACE_SV_Semaphore_Simple> allocator; +ACE_SV_Semaphore_Complex *mutex = 0; +ACE_SV_Semaphore_Complex *synch = 0; + +/* Pointer to memory shared by both the client and server. */ +static char *shm; + +static int +do_parent (void) +{ + char *s = shm; + + mutex = new ACE_SV_Semaphore_Complex (SEM_KEY_1, ACE_SV_Semaphore_Complex::ACE_CREATE, 0); + synch = new ACE_SV_Semaphore_Complex (SEM_KEY_2, ACE_SV_Semaphore_Complex::ACE_CREATE, 0); + + for (char c = 'a'; c <= 'z'; c++) + *s++ = c; + + *s = '\0'; + + if (mutex->release () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p", "server mutex.release"), 1); + + if (synch->acquire () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p", "server synch.acquire"), 1); + return 0; +} + +static int +do_child (void) +{ + mutex = new ACE_SV_Semaphore_Complex (SEM_KEY_1, ACE_SV_Semaphore_Complex::ACE_CREATE, 0); + synch = new ACE_SV_Semaphore_Complex (SEM_KEY_2, ACE_SV_Semaphore_Complex::ACE_CREATE, 0); + + while (mutex->tryacquire () == -1) + if (errno == EAGAIN) + ACE_DEBUG ((LM_DEBUG, "spinning in client!\n")); + else + ACE_ERROR_RETURN ((LM_ERROR, "client mutex.tryacquire"), 1); + + for (char *s = (char *) shm; *s != '\0'; s++) + putchar (*s); + + putchar ('\n'); + + if (synch->release () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "client synch.release"), 1); + return 0; +} + +int +main (void) +{ + shm = (char *) allocator.malloc (27); + + switch (ACE_OS::fork ()) + { + case -1: + ACE_ERROR_RETURN ((LM_ERROR, "fork failed\n"), -1); + /* NOTREACHED */ + case 0: + return do_child (); + default: + { + int result = do_parent (); + + if (wait (0) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "wait"), -1); + + allocator.remove (); + + if (mutex->remove () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "mutex.remove"), -1); + else if (synch->remove () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "synch.remove"), -1); + return result; + } + } +} + +#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +template class ACE_Malloc<ACE_Shared_Memory_Pool, ACE_SV_Semaphore_Simple>; +#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ + diff --git a/examples/System_V_IPC/SV_Shared_Memory/Makefile b/examples/System_V_IPC/SV_Shared_Memory/Makefile new file mode 100644 index 00000000000..a950c681250 --- /dev/null +++ b/examples/System_V_IPC/SV_Shared_Memory/Makefile @@ -0,0 +1,54 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for tests of the SV_Shared_Memory wrapper +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = SV_Shared_Memory_Test + +LSRC = $(addsuffix .cpp,$(BIN)) + +LDLIBS = + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +INSTALL = + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/SV_Shared_Memory_Test.o .shobj/SV_Shared_Memory_Test.so: SV_Shared_Memory_Test.cpp \ + $(WRAPPER_ROOT)/ace/SV_Shared_Memory.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + SV_Shared_Memory_Test.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/System_V_IPC/SV_Shared_Memory/SV_Shared_Memory_Test.cpp b/examples/System_V_IPC/SV_Shared_Memory/SV_Shared_Memory_Test.cpp new file mode 100644 index 00000000000..3b1fa48ceb5 --- /dev/null +++ b/examples/System_V_IPC/SV_Shared_Memory/SV_Shared_Memory_Test.cpp @@ -0,0 +1,60 @@ +#include "ace/SV_Shared_Memory.h" +// @(#)SV_Shared_Memory_Test.cpp 1.1 10/18/96 + +#include "SV_Shared_Memory_Test.h" + +static void +client (void) +{ + ACE_SV_Shared_Memory shm_client; + + if (shm_client.open_and_attach (SHM_KEY, SHMSZ) == -1) + ACE_OS::perror ("open"), ACE_OS::exit (1); + + for (char *s = (char *) shm_client.get_segment_ptr (); *s != '\0'; s++) + putchar (*s); + + putchar ('\n'); + *(char *) shm_client.get_segment_ptr () = '*'; + ACE_OS::exit (0); +} + +static void +server (void) +{ + ACE_SV_Shared_Memory shm_server; + + if (shm_server.open_and_attach (SHM_KEY, SHMSZ, ACE_SV_Shared_Memory::ACE_CREATE) == -1) + ACE_OS::perror ("open"), ACE_OS::exit (1); + + char *s = (char *) shm_server.get_segment_ptr (); + + for (char c = 'a'; c <= 'z'; c++) + *s++ = c; + + *s = '\0'; + + for (s = (char *) shm_server.get_segment_ptr (); *s != '*'; ) + ACE_OS::sleep (1); + + if (shm_server.remove () < 0) + ACE_OS::perror ("remove"), ACE_OS::exit (1); + ACE_OS::exit (0); +} + +int +main (int, char *argv[]) +{ + switch (ACE_OS::fork ()) + { + case -1: + ACE_OS::perror (argv[0]), ACE_OS::exit (1); + case 0: + ACE_OS::sleep (1); + client (); + default: + server (); + } + return 0; +} + diff --git a/examples/System_V_IPC/SV_Shared_Memory/SV_Shared_Memory_Test.h b/examples/System_V_IPC/SV_Shared_Memory/SV_Shared_Memory_Test.h new file mode 100644 index 00000000000..795e9180f65 --- /dev/null +++ b/examples/System_V_IPC/SV_Shared_Memory/SV_Shared_Memory_Test.h @@ -0,0 +1,7 @@ +/* -*- C++ -*- */ +// @(#)SV_Shared_Memory_Test.h 1.1 10/18/96 + +#include "ace/OS.h" +#define SHMSZ 27 +#define SEM_KEY 1234 +#define SHM_KEY 5678 diff --git a/examples/Threads/Makefile b/examples/Threads/Makefile new file mode 100644 index 00000000000..a518bf6c293 --- /dev/null +++ b/examples/Threads/Makefile @@ -0,0 +1,1004 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for tests of the ACE thread wrappers +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = test_auto_event \ + test_barrier1 \ + test_barrier2 \ + test_future1 \ + test_future2 \ + test_manual_event \ + test_process_mutex \ + test_process_semaphore \ + test_reader_writer \ + test_recursive_mutex \ + test_task \ + test_task_two \ + test_task_three \ + test_thread_manager \ + test_thread_pool \ + test_thread_specific \ + test_tss \ + test_token + +LSRC = $(addsuffix .cpp,$(BIN)) +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +LIBS += -lm +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/test_barrier1.o .shobj/test_barrier1.so: test_barrier1.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h +.obj/test_barrier2.o .shobj/test_barrier2.so: test_barrier2.cpp \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Task.i +.obj/test_future1.o .shobj/test_future1.so: test_future1.cpp \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Future.h \ + $(WRAPPER_ROOT)/ace/Future.cpp \ + $(WRAPPER_ROOT)/ace/Method_Object.h \ + $(WRAPPER_ROOT)/ace/Activation_Queue.h \ + $(WRAPPER_ROOT)/ace/Auto_Ptr.h \ + $(WRAPPER_ROOT)/ace/Auto_Ptr.cpp \ + $(WRAPPER_ROOT)/ace/Auto_Ptr.i +.obj/test_future2.o .shobj/test_future2.so: test_future2.cpp \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Task.i \ + $(WRAPPER_ROOT)/ace/Future.h \ + $(WRAPPER_ROOT)/ace/Future.cpp \ + $(WRAPPER_ROOT)/ace/Method_Object.h \ + $(WRAPPER_ROOT)/ace/Activation_Queue.h \ + $(WRAPPER_ROOT)/ace/Auto_Ptr.h \ + $(WRAPPER_ROOT)/ace/Auto_Ptr.cpp \ + $(WRAPPER_ROOT)/ace/Auto_Ptr.i +.obj/test_process_mutex.o .shobj/test_process_mutex.so: test_process_mutex.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i +.obj/test_process_semaphore.o .shobj/test_process_semaphore.so: test_process_semaphore.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i +.obj/test_reader_writer.o .shobj/test_reader_writer.so: test_reader_writer.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Get_Opt.h +.obj/test_recursive_mutex.o .shobj/test_recursive_mutex.so: test_recursive_mutex.cpp \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Get_Opt.h +.obj/test_task.o .shobj/test_task.so: test_task.cpp \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Task.i +.obj/test_task_two.o .shobj/test_task_two.so: test_task_two.cpp \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Task.i +.obj/test_task_three.o .shobj/test_task_three.so: test_task_three.cpp \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Task.i +.obj/test_thread_manager.o .shobj/test_thread_manager.so: test_thread_manager.cpp \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h +.obj/test_thread_pool.o .shobj/test_thread_pool.so: test_thread_pool.cpp \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Task.i +.obj/test_thread_specific.o .shobj/test_thread_specific.so: test_thread_specific.cpp \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h +.obj/test_tss.o .shobj/test_tss.so: test_tss.cpp \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Task.i +.obj/test_token.o .shobj/test_token.so: test_token.cpp \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Set.cpp \ + $(WRAPPER_ROOT)/ace/Set.i \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Task.cpp \ + $(WRAPPER_ROOT)/ace/Module.h \ + $(WRAPPER_ROOT)/ace/Module.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.h \ + $(WRAPPER_ROOT)/ace/Stream_Modules.cpp \ + $(WRAPPER_ROOT)/ace/Stream_Modules.i \ + $(WRAPPER_ROOT)/ace/Module.i \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Task.i + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/Threads/test_auto_event.cpp b/examples/Threads/test_auto_event.cpp new file mode 100644 index 00000000000..24de2e9d230 --- /dev/null +++ b/examples/Threads/test_auto_event.cpp @@ -0,0 +1,106 @@ +// This test shows the use of an ACE_Auto_Event as a signaling +// @(#)test_auto_event.cpp 1.1 10/18/96 + +// mechanism. Two threads are created (one a reader, the other a +// writer). The reader waits till the writer has completed +// calculations. Upon waking up the reader prints the data calculated +// by the writer. The writer thread calculates the value and signals +// the reader when the calculation completes. + +#include "ace/Service_Config.h" +#include "ace/Synch.h" +#include "ace/Singleton.h" +#include "ace/Thread_Manager.h" + +// Shared event between reader and writer. The ACE_Thread_Mutex is +// necessary to make sure that only one ACE_Auto_Event is created. +// The default constructor for ACE_Auto_Event sets it initially into +// the non-signaled state. + +typedef ACE_Singleton <ACE_Auto_Event, ACE_Thread_Mutex> EVENT; + +// work time for writer +static int work_time; + +// Reader thread. +static void * +reader (void *arg) +{ + // Shared data via a reference. + int& data = *(int *) arg; + + ACE_Thread_Control tc (ACE_Service_Config::thr_mgr ()); + + // Wait for writer to complete. + + ACE_DEBUG ((LM_DEBUG, "(%t) reader: waiting...... \n")); + + if (EVENT::instance ()->wait () == -1) + { + ACE_ERROR ((LM_ERROR, "thread wait failed")); + ACE_OS::exit (0); + } + + // Read shared data. + ACE_DEBUG ((LM_DEBUG, "(%t) reader: value of data is: %d \n", data)); + + return 0; +} + +// Writer thread. +static void * +writer (void *arg) +{ + int result; + + int& data = *(int *) arg; + + ACE_Thread_Control tc (ACE_Service_Config::thr_mgr ()); + + // Calculate (work). + ACE_DEBUG ((LM_DEBUG, "(%t) writer: working for %d secs\n", work_time)); + ACE_OS::sleep (work_time); + + // Write shared data. + data = 42; + + // Wake up reader. + ACE_DEBUG ((LM_DEBUG, "(%t) writer: calculation complete, waking reader\n")); + + if (EVENT::instance ()->signal () == -1) + { + ACE_ERROR ((LM_ERROR, "thread wait failed")); + ACE_OS::exit (0); + } + + return 0; +} + +int +main (int argc, char **argv) +{ + // Shared data: set by writer, read by reader. + int data; + + // Work time for writer. + work_time = argc == 2 ? atoi (argv[1]) : 5; + + // threads manager + ACE_Thread_Manager& tm = *ACE_Service_Config::thr_mgr (); + + // Create reader thread. + if (tm.spawn (reader, (void *) &data) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "thread create for reader failed"), -1); + + // Create writer thread. + if (tm.spawn (writer, (void *) &data) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "thread create for writer failed"), -1); + + // Wait for both. + if (tm.wait () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "thread wait failed"), -1); + else + ACE_DEBUG ((LM_ERROR, "graceful exit\n")); + + return 0; +} diff --git a/examples/Threads/test_barrier1.cpp b/examples/Threads/test_barrier1.cpp new file mode 100644 index 00000000000..2bd0b916b31 --- /dev/null +++ b/examples/Threads/test_barrier1.cpp @@ -0,0 +1,84 @@ +// This test program illustrates how the ACE barrier synchronization +// @(#)test_barrier1.cpp 1.1 10/18/96 + +// mechanisms work. + +#include "ace/Log_Msg.h" +#include "ace/Synch.h" +#include "ace/Thread_Manager.h" +#include "ace/Service_Config.h" + +#if defined (ACE_HAS_THREADS) + +struct Tester_Args + // = TITLE + // These arguments are passed into each test thread. +{ + Tester_Args (ACE_Barrier &tb, int i) + : tester_barrier_ (tb), + n_iterations_ (i) {} + + ACE_Barrier &tester_barrier_; + // Reference to the tester barrier. This controls each miteration of + // the tester function running in every thread. + + int n_iterations_; + // Number of iterations to run. +}; + +// Iterate <n_iterations> time printing off a message and "waiting" +// for all other threads to complete this iteration. + +static void * +tester (Tester_Args *args) +{ + // Keeps track of thread exit. + ACE_Thread_Control tc (ACE_Service_Config::thr_mgr ()); + + for (int iterations = 1; + iterations <= args->n_iterations_; + iterations++) + { + ACE_DEBUG ((LM_DEBUG, "(%t) in iteration %d\n", iterations)); + + // Block until all other threads have waited, then continue. + args->tester_barrier_.wait (); + } + + return 0; +} + +// Default number of threads to spawn. +static const int DEFAULT_ITERATIONS = 5; + +int +main (int argc, char *argv[]) +{ + ACE_Service_Config daemon (argv[0]); + + int n_threads = argc > 1 ? ACE_OS::atoi (argv[1]) : ACE_DEFAULT_THREADS; + int n_iterations = argc > 2 ? ACE_OS::atoi (argv[2]) : DEFAULT_ITERATIONS; + + ACE_Barrier tester_barrier (n_threads); + + Tester_Args args (tester_barrier, n_iterations); + + if (ACE_Service_Config::thr_mgr ()->spawn_n + (n_threads, ACE_THR_FUNC (tester), + (void *) &args, THR_NEW_LWP | THR_DETACHED) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn_n"), 1); + + // Wait for all the threads to reach their exit point. + ACE_Service_Config::thr_mgr ()->wait (); + + ACE_DEBUG ((LM_DEBUG, "(%t) done\n")); + return 0; +} +#else +int +main (int, char *[]) +{ + ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); + return 0; +} +#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_barrier2.cpp b/examples/Threads/test_barrier2.cpp new file mode 100644 index 00000000000..11cb8e1da0b --- /dev/null +++ b/examples/Threads/test_barrier2.cpp @@ -0,0 +1,272 @@ +// generic_worker_task.cpp +// @(#)test_barrier2.cpp 1.1 10/18/96 + +// +// This test program illustrates how the ACE task workers/barrier +// synchronization mechanisms work in conjunction with the ACE_Task +// and the ACE_Thread_Manager. The manual flag not set simulates +// user input, if set input comes from stdin until RETURN only is +// entered which stops all workers via a message block of length +// 0. This is an alernative shutdown of workers compared to queue +// deactivate. The delay_put flag simulates a delay between the +// shutdown puts. All should work with this flag disabled! The +// BARRIER_TYPE is supposed to enable/disable barrier sync on each svc +// a worker has done. + +#include <iostream.h> +#include "ace/Task.h" +#include "ace/Service_Config.h" +#include "ace/Log_Msg.h" + +#if defined (ACE_HAS_THREADS) + +#define BARRIER_TYPE ACE_Null_Barrier +//#define BARRIER_TYPE ACE_Barrier +//#ifdef delay_put +//#define manual + +template <class BARRIER> +class Worker_Task : public ACE_Task<ACE_MT_SYNCH> +{ +public: + + Worker_Task (ACE_Thread_Manager *thr_mgr, + int n_threads, + int inp_serialize = 1); + + virtual int Producer (void); + // produce input for workers + + virtual int input (ACE_Message_Block *mb); + // Fill one message block via a certain input strategy. + + virtual int output (ACE_Message_Block *mb); + // Forward one message block via a certain output strategy to the + // next task if any. + + virtual int service (ACE_Message_Block *mb, int iter); + // Perform one message block dependant service. + +private: + virtual int put (ACE_Message_Block *mb, ACE_Time_Value *tv=0); + + virtual int svc (void); + // Iterate <n_iterations> time printing off a message and "waiting" + // for all other threads to complete this iteration. + + // = Not needed for this test. + virtual int open (void *) { return 0; } + virtual int close (u_long) {ACE_DEBUG ((LM_DEBUG,"(%t) in close of worker\n")); return 0; } + + int nt_; + // Number of worker threads to run. + int inp_serialize_; + + BARRIER barrier_; +}; + +template <class BARRIER> +Worker_Task<BARRIER>::Worker_Task (ACE_Thread_Manager *thr_mgr, + int n_threads, + int inp_serialize) + : ACE_Task<ACE_MT_SYNCH> (thr_mgr), + barrier_ (n_threads) +{ + nt_ = n_threads; + // Create worker threads. + inp_serialize_ = inp_serialize; + + // Use the task's message queue for serialization (default) or run + // service in the context of the caller thread. + + if (nt_ > 0 && inp_serialize == 1) + if (this->activate (THR_NEW_LWP, n_threads) == -1) + ACE_ERROR ((LM_ERROR, "%p\n", "activate failed")); +} + + + +// Simply enqueue the Message_Block into the end of the queue. + +template <class BARRIER> int +Worker_Task<BARRIER>::put (ACE_Message_Block *mb, ACE_Time_Value *tv) +{ + int result; + if (this->inp_serialize_) + result = this->putq (mb, tv); + else + { + static int iter = 0; + result = this->service (mb, iter++); + + if (this->output (mb) < 0) + ACE_DEBUG ((LM_DEBUG, "(%t) output not connected!\n")); + + delete mb; + } + return result; +} + +template <class BARRIER> int +Worker_Task<BARRIER>::service (ACE_Message_Block *mb, int iter) +{ + int length = mb->length (); + + if (length > 0) + { + ACE_DEBUG ((LM_DEBUG,"(%t) in iteration %d len=%d text got:\n",iter,length)); + ACE_OS::write (ACE_STDOUT, mb->rd_ptr (), length); + ACE_DEBUG ((LM_DEBUG,"\n")); + } + return 0; +} + +// Iterate <n_iterations> time printing off a message and "waiting" +// for all other threads to complete this iteration. + +template <class BARRIER> int +Worker_Task<BARRIER>::svc (void) +{ + // Note that the ACE_Task::svc_run () method automatically adds us + // to the Thread_Manager when the thread begins. + + // Keep looping, reading a message out of the queue, until we get a + // message with a length == 0, which signals us to quit. + + for (int iter = 1; ;iter++) + { + ACE_Message_Block *mb = 0; + + int result = this->getq (mb); + + if (result == -1) + { + ACE_ERROR ((LM_ERROR, + "(%t) in iteration %d\n", "error waiting for message in iteration", iter)); + break; + } + + int length = mb->length (); + this->service (mb,iter); + + if (length == 0) + { + ACE_DEBUG ((LM_DEBUG, "(%t) in iteration %d got quit, exit!\n", iter)); + delete mb; + break; + } + + this->barrier_.wait (); + this->output (mb); + + delete mb; + } + + // Note that the ACE_Task::svc_run () method automatically removes + // us from the Thread_Manager when the thread exits. + + return 0; +} + +template <class BARRIER> int +Worker_Task<BARRIER>::Producer (void) +{ + // Keep reading stdin, until we reach EOF. + + for (;;) + { + // Allocate a new message. + ACE_Message_Block *mb = new ACE_Message_Block (BUFSIZ); + + if (this->input (mb) == -1) + return -1; + } + + return 0; +} + +template <class BARRIER>int +Worker_Task<BARRIER>::output (ACE_Message_Block *mb) +{ + return this->put_next (mb); +} + +template <class BARRIER>int +Worker_Task<BARRIER>::input (ACE_Message_Block *mb) +{ + ACE_Message_Block *mb1; + +#ifndef manual + static int l= 0; + char str[]="kalle"; + strcpy (mb->rd_ptr (),str); + int n=strlen (str); + if (l==1000) + n=1; + l++; + if (l==0 || (l%100 == 0)) ACE_OS::sleep (5); + if (n <= 1) +#else + ACE_DEBUG ((LM_DEBUG,"(%t) press chars and enter to put a new message into task queue ...\n")); + if ((n = read (0, mb->rd_ptr (), mb->size ())) <= 1) +#endif // manual + { + // Send a shutdown message to the waiting threads and exit. + // cout << "\nvor loop, dump of task msg queue:\n" << endl; + // this->msg_queue ()->dump (); + for (int i=0;i<nt_;i++) + { + ACE_DEBUG ((LM_DEBUG,"(%t) eof, sending block for thread=%d\n",i+1)); + mb1 = new ACE_Message_Block (2); + mb1->length (0); + if (this->put (mb1) == -1) + ACE_ERROR ((LM_ERROR, "(%t) %p\n", "put")); +#ifdef delay_put + ACE_OS::sleep (1); // this sleep helps to shutdown correctly -> was an error! +#endif delay_put + } + // cout << "\nnach loop, dump of task msg queue:\n" << endl; + // this->msg_queue ()->dump (); + return (-1); + } + else + { + // Send a normal message to the waiting threads and continue producing. + mb->wr_ptr (n); + if (this->put (mb) == -1) + ACE_ERROR ((LM_ERROR, "(%t) %p\n", "put")); + } + return 0; +} + +int +main (int argc, char *argv[]) +{ + int n_threads = argc > 1 ? ACE_OS::atoi (argv[1]) : ACE_DEFAULT_THREADS; + + ACE_DEBUG ((LM_DEBUG,"(%t) worker threads running=%d\n",n_threads)); + + + Worker_Task<BARRIER_TYPE> *worker_task = + new Worker_Task<BARRIER_TYPE> (ACE_Service_Config::thr_mgr (), + /*n_threads*/ 0,0); + + worker_task->Producer (); + + // Wait for all the threads to reach their exit point. + ACE_DEBUG ((LM_DEBUG,"(%t) waiting with thread manager ...\n")); + ACE_Service_Config::thr_mgr ()->wait (); + ACE_DEBUG ((LM_DEBUG,"(%t) delete worker task ...\n")); + + delete worker_task; + ACE_DEBUG ((LM_DEBUG,"(%t) done correct!\n")); + return 0; +} +#else +int +main (int, char *[]) +{ + ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); + return 0; +} +#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_cancel.cpp b/examples/Threads/test_cancel.cpp new file mode 100644 index 00000000000..9d14e4684b0 --- /dev/null +++ b/examples/Threads/test_cancel.cpp @@ -0,0 +1,72 @@ +// Test out the cooperative thread cancellation mechanisms provided by +// @(#)test_cancel.cpp 1.1 10/18/96 + +// the ACE_Thread_Manager. + +#include "ace/Service_Config.h" +#include "ace/Thread_Manager.h" + +#if defined (ACE_HAS_THREADS) + +static void * +worker (int iterations) +{ + for (int i = 0; i < iterations; i++) + { + if ((i % 10) == 0 + && (ACE_Service_Config::thr_mgr ()->testcancel (ACE_Thread::self ()) != 0)) + { + ACE_DEBUG ((LM_DEBUG, "(%t) has been cancelled before iteration!\n", i)); + break; + } + } + + return 0; +} + +static const int DEFAULT_THREADS = ACE_DEFAULT_THREADS; +static const int DEFAULT_ITERATIONS = 100000; + +int +main (int argc, char *argv[]) +{ + ACE_Service_Config daemon; + + daemon.open (argv[0]); + + int n_threads = argc > 1 ? ACE_OS::atoi (argv[1]) : DEFAULT_THREADS; + int n_iterations = argc > 2 ? ACE_OS::atoi (argv[2]) : DEFAULT_ITERATIONS; + + ACE_Thread_Manager *thr_mgr = ACE_Service_Config::thr_mgr (); + + int grp_id = thr_mgr->spawn_n (n_threads, ACE_THR_FUNC (worker), + (void *) n_iterations, + THR_NEW_LWP | THR_DETACHED); + + // Wait for 2 seconds and then suspend every thread in the group. + ACE_OS::sleep (2); + thr_mgr->suspend_grp (grp_id); + + // Wait for 2 more seconds and then resume every thread in the + // group. + ACE_OS::sleep (ACE_Time_Value (2)); + thr_mgr->resume_grp (grp_id); + + // Wait for 2 more seconds and then send a SIGINT to every thread in + // the group. + ACE_OS::sleep (ACE_Time_Value (2)); + thr_mgr->kill_grp (grp_id, SIGINT); + + // Wait for 2 more seconds and then exit (which should kill all the + // threads)! + ACE_OS::sleep (ACE_Time_Value (2)); + + return 0; +} +#else +int +main (int, char *[]) +{ + ACE_ERROR_RETURN ((LM_ERROR, "threads not supported on this platform\n"), -1); +} +#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_future1.cpp b/examples/Threads/test_future1.cpp new file mode 100644 index 00000000000..ad725ef5023 --- /dev/null +++ b/examples/Threads/test_future1.cpp @@ -0,0 +1,420 @@ +// ============================================================================ +// @(#)test_future1.cpp 1.1 10/18/96 + +// +// = LIBRARY +// tests +// +// = FILENAME +// Test_Future.cpp +// +// = DESCRIPTION +// This example tests the ACE Future. +// +// = AUTHOR +// Andres Kruse <Andres.Kruse@cern.ch> and Douglas C. Schmidt +// <schmidt@cs.wustl.edu> +// +// ============================================================================ + +#include <math.h> +#include "ace/Task.h" +#include "ace/Log_Msg.h" +#include "ace/Synch.h" +#include "ace/Message_Queue.h" +#include "ace/Future.h" +#include "ace/Method_Object.h" +#include "ace/Activation_Queue.h" +#include "ace/Auto_Ptr.h" + +#if defined (ACE_HAS_THREADS) + +typedef ACE_Atomic_Op<ACE_Thread_Mutex, u_long> ATOMIC_INT; + +// a counter for the tasks.. +static ATOMIC_INT task_count (0); + +// a counter for the futures.. +static ATOMIC_INT future_count (0); +static ATOMIC_INT future_no (0); + +// a counter for the capsules.. +static ATOMIC_INT capsule_count (0); +static ATOMIC_INT capsule_no (0); + +// a counter for the method objects... +static ATOMIC_INT methodobject_count (0); +static ATOMIC_INT methodobject_no (0); + +class Scheduler : public ACE_Task<ACE_MT_SYNCH> + // = TITLE + // Active Object Scheduler. +{ + friend class Method_ObjectWork; +public: + Scheduler (const char *, Scheduler * = 0); + ~Scheduler (void); + + virtual int open (void *args = 0); + virtual int close (u_long flags = 0); + virtual int put (ACE_Message_Block *mb, ACE_Time_Value *tv = 0); + virtual int svc (void); + + ACE_Future<float> work (float param, int count); + ACE_Future<const char*> name (void); + void end (void); + + float work_i (float, int); + const char *name_i (void); + +private: + const char *name_; + ACE_Activation_Queue activation_queue_; + Scheduler *scheduler_; + +}; + +class Method_Object_work : public ACE_Method_Object + // = TITLE + // Reification of the <work> method. +{ +public: + Method_Object_work (Scheduler *, float, int, ACE_Future<float> &); + ~Method_Object_work (void); + virtual int call (void); + +private: + Scheduler *scheduler_; + float param_; + int count_; + ACE_Future<float> future_result_; +}; + +Method_Object_work::Method_Object_work (Scheduler* new_Scheduler, + float new_param, + int new_count, + ACE_Future<float> &new_result) + : scheduler_ (new_Scheduler), + param_ (new_param), + count_ (new_count), + future_result_ (new_result) +{ + ACE_DEBUG ((LM_DEBUG, + "(%t) Method_Object_work created\n")); +} + +Method_Object_work::~Method_Object_work (void) +{ + ACE_DEBUG ((LM_DEBUG, "(%t) Method_Object_work will be deleted.\n")); +} + + +int +Method_Object_work::call (void) +{ + return this->future_result_.set (this->scheduler_->work_i (this->param_, this->count_)); +} + +class Method_Object_name : public ACE_Method_Object + // = TITLE + // Reification of the <name> method. +{ +public: + Method_Object_name (Scheduler *, ACE_Future<const char*> &); + ~Method_Object_name (void); + virtual int call (void); + +private: + Scheduler *scheduler_; + ACE_Future<const char*> future_result_; +}; + +Method_Object_name::Method_Object_name (Scheduler *new_scheduler, + ACE_Future<const char*> &new_result) + : scheduler_ (new_scheduler), + future_result_ (new_result) +{ + ACE_DEBUG ((LM_DEBUG, + "(%t) Method_Object_name created\n")); +}; + +Method_Object_name::~Method_Object_name (void) +{ + ACE_DEBUG ((LM_DEBUG, + "(%t) Method_Object_name will be deleted.\n")); +} + +int +Method_Object_name::call (void) +{ + return future_result_.set (scheduler_->name_i ()); +} + +class Method_Object_end : public ACE_Method_Object + // = TITLE + // Reification of the <end> method. +{ +public: + Method_Object_end (Scheduler *new_Scheduler): scheduler_ (new_Scheduler) {} + ~Method_Object_end (void) {} + virtual int call (void) { this->scheduler_->close (); return -1; } + +private: + Scheduler *scheduler_; +}; + +// constructor +Scheduler::Scheduler (const char *newname, Scheduler *new_Scheduler) +{ + ACE_NEW (this->name_, char[ACE_OS::strlen (newname) + 1]); + ACE_OS::strcpy ((char *) this->name_, newname); + this->scheduler_ = new_Scheduler; + ACE_DEBUG ((LM_DEBUG, "(%t) Scheduler %s created\n", this->name_)); +} + +// Destructor +Scheduler::~Scheduler (void) +{ + ACE_DEBUG ((LM_DEBUG, "(%t) Scheduler %s will be destroyed\n", this->name_)); +} + +// open +int +Scheduler::open (void *args) +{ + task_count++; + ACE_DEBUG ((LM_DEBUG, "(%t) Scheduler %s open\n", this->name_)); + return this->activate (THR_BOUND); +} + +// close +int +Scheduler::close (u_long flags) +{ + ACE_DEBUG ((LM_DEBUG, "(%t) Scheduler %s close\n", this->name_)); + task_count--; + return 0; +} + +// put... ?? +int +Scheduler::put (ACE_Message_Block *mb, ACE_Time_Value *tv) +{ + return 0; +} + +// service.. +int +Scheduler::svc (void) +{ + for (;;) + { + // Dequeue the next method object (we use an auto pointer in + // case an exception is thrown in the <call>). + auto_ptr<ACE_Method_Object> mo (this->activation_queue_.dequeue ()); + + ACE_DEBUG ((LM_DEBUG, "(%t) calling method object\n")); + // Call it. + if (mo->call () == -1) + break; + // Destructor automatically deletes it. + } + + /* NOTREACHED */ + return 0; +} + +void +Scheduler::end (void) +{ + this->activation_queue_.enqueue (new Method_Object_end (this)); +} + + +// Here's where the Work takes place. +float +Scheduler::work_i (float param, + int count) +{ + float x = 0, y = 0; + + // @@ We should probably do something fun here, like compute the + // Fibonacci sequence or something. + + for (int j = 0; j < count; j++) + { + x = x + param; + y = y + ::sin (x); + } + + return y; +} + +const char * +Scheduler::name_i (void) +{ + char *the_name; + + the_name = new char[ACE_OS::strlen (this->name_) + 1]; + ACE_OS::strcpy (the_name, this->name_); + + return the_name; +} + +ACE_Future<const char *> +Scheduler::name (void) +{ + if (this->scheduler_) + // Delegate to the Scheduler. + return this->scheduler_->name (); + else + { + ACE_Future<const char*> new_future; + + // @@ What happens if new fails here? + this->activation_queue_.enqueue + (new Method_Object_name (this, new_future)); + + return new_future; + } +} + +ACE_Future<float> +Scheduler::work (float newparam, int newcount) +{ + if (this->scheduler_) { + return this->scheduler_->work (newparam, newcount); + } + else { + ACE_Future<float> new_future; + + this->activation_queue_.enqueue + (new Method_Object_work (this, newparam, newcount, new_future)); + return new_future; + } +} + +// @@ These values should be set by the command line options! + +// Total number of iterations to <work> +static int n_iterations = 50000; + +// Total number of loops. +static int n_loops = 100; + +int +main (int argc, char *argv[]) +{ + Scheduler *andres, *peter, *helmut, *matias; + + // Create active objects.. + // @@ Should "open" be subsumed within the constructor of + // Scheduler()? + andres = new Scheduler ("andres"); + andres->open (); + peter = new Scheduler ("peter"); + peter->open (); + helmut = new Scheduler ("helmut"); + helmut->open (); + + // Matias passes all asynchronous method calls on to Andres... + matias = new Scheduler ("matias", andres); + matias->open (); + + for (int i = 0; i < n_loops; i++) + { + { + ACE_Future<float> fresulta, fresultb, fresultc, fresultd, fresulte; + ACE_Future<const char*> fname; + + ACE_DEBUG ((LM_DEBUG, "(%t) going to do a non-blocking call\n")); + + fresulta = andres->work (0.01, 100 + (n_iterations * (i % 2))); + fresultb = peter->work (0.01, 100 + (n_iterations * (i % 2))); + fresultc = helmut->work (0.01, 100 + (n_iterations * (i % 2))); + fresultd = matias->work (0.02, 100 + (n_iterations * (i % 2))); + fname = andres->name (); + + // see if the result is available... + if (fresulta.ready ()) + ACE_DEBUG ((LM_DEBUG, "(%t) wow.. work is ready.....\n")); + + ACE_DEBUG ((LM_DEBUG, "(%t) non-blocking call done... now blocking...\n")); + + // Save the result of fresulta. + + fresulte = fresulta; + + if (i % 3 == 0) + { + // Every 3rd time... disconnect the futures... + // but "fresulte" should still contain the result... + fresulta.cancel (10.0); + fresultb.cancel (20.0); + fresultc.cancel (30.0); + fresultd.cancel (40.0); + } + + float resulta = 0, resultb = 0, resultc = 0, resultd = 0, resulte = 0; + + fresulta.get (resulta); + fresultb.get (resultb); + fresultc.get (resultc); + fresultd.get (resultd); + fresulte.get (resulte); + + ACE_DEBUG ((LM_DEBUG, "(%t) result a %f\n", resulte)); + ACE_DEBUG ((LM_DEBUG, "(%t) result b %f\n", resulta)); + ACE_DEBUG ((LM_DEBUG, "(%t) result c %f\n", resultb)); + ACE_DEBUG ((LM_DEBUG, "(%t) result d %f\n", resultc)); + ACE_DEBUG ((LM_DEBUG, "(%t) result e %f\n", resultd)); + + const char *name; + + fname.get (name); + + ACE_DEBUG ((LM_DEBUG, "(%t) name %s\n", name)); + + } + + ACE_DEBUG ((LM_DEBUG, + "(%t) task_count %d future_count %d capsule_count %d methodobject_count %d\n", + (u_long) task_count, + (u_long) future_count, + (u_long) capsule_count, + (u_long) methodobject_count)); + } + + // Close things down. + andres->end (); + peter->end (); + helmut->end (); + matias->end (); + + ACE_OS::sleep (2); + + ACE_DEBUG ((LM_DEBUG, + "(%t) task_count %d future_count %d capsule_count %d methodobject_count %d\n", + (u_long) task_count, + (u_long) future_count, + (u_long) capsule_count, + (u_long) methodobject_count)); + + ACE_DEBUG ((LM_DEBUG,"(%t) th' that's all folks!\n")); + + ACE_OS::sleep (5); + return 0; +} + +#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +template class ACE_Atomic_Op<ACE_Thread_Mutex, u_long>; +#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ + +#else +int +main (int, char *[]) +{ + ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); + return 0; +} +#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_future2.cpp b/examples/Threads/test_future2.cpp new file mode 100644 index 00000000000..f565fbeb725 --- /dev/null +++ b/examples/Threads/test_future2.cpp @@ -0,0 +1,524 @@ +// ============================================================================ +// @(#)test_future2.cpp 1.1 10/18/96 + +// +// = LIBRARY +// tests +// +// = FILENAME +// Test_Future.cpp +// +// = DESCRIPTION +// This example tests the ACE Future. +// +// = AUTHOR +// Andres Kruse <Andres.Kruse@cern.ch> and Douglas C. Schmidt +// <schmidt@cs.wustl.edu> +// +// Modification History +// Aug. 96; A.Kruse; dev. +// Aug. 96; D.Schmidt; complete workover +// 08/27/96; A.Kruse; - the friends of Scheduler are "Method_Object_name" +// and "Method_Object_work". +// - make the methods "work_i" and "name_i" private +// 09/2/96; D.Schmidt; Integrate with new ACE_Future API and rearrange +// the tests so they are more modular. +// ============================================================================ + +#include <math.h> +#include "ace/Task.h" +#include "ace/Log_Msg.h" +#include "ace/Synch.h" +#include "ace/Message_Queue.h" +#include "ace/Future.h" +#include "ace/Method_Object.h" +#include "ace/Activation_Queue.h" +#include "ace/Auto_Ptr.h" + +#if defined (ACE_HAS_THREADS) + +typedef ACE_Atomic_Op<ACE_Thread_Mutex, u_long> ATOMIC_INT; + +// a counter for the tasks.. +static ATOMIC_INT scheduler_open_count (0); + +// forward declarations +class Method_Object_work; +class Method_Object_name; + +class Scheduler : public ACE_Task<ACE_MT_SYNCH> + // = TITLE + // Active Object Scheduler. +{ + // Every method object has to be able to access the private methods. + + friend class Method_Object_work; + friend class Method_Object_name; + friend class Method_Object_end; +public: + + Scheduler (const char *, Scheduler * = 0); + ~Scheduler (void); + + virtual int open (void *args = 0); + // The method that is used to start the active object. + + // = Here are the methods exported by the class. They return an + // <ACE_Future>. + ACE_Future<float> work (float param, int count); + ACE_Future<char*> name (void); + void end (void); + +private: + virtual int close (u_long flags = 0); + // Should not be accessible from outside... (use end () instead). + + virtual int put (ACE_Message_Block *mb, ACE_Time_Value *tv = 0) + { return 0; }; + // Doesn't have any use for this example. + + virtual int svc (void); + // Here the actual servicing of all requests is happening.. + + // = Implementation methods. + float work_i (float, int); + char *name_i (void); + + const char *name_; + ACE_Activation_Queue activation_queue_; + Scheduler *scheduler_; +}; + +class Method_Object_work : public ACE_Method_Object + // = TITLE + // Reification of the <work> method. +{ +public: + Method_Object_work (Scheduler *, float, int, ACE_Future<float> &); + ~Method_Object_work (void); + virtual int call (void); + +private: + Scheduler *scheduler_; + float param_; + int count_; + ACE_Future<float> future_result_; +}; + +Method_Object_work::Method_Object_work (Scheduler* new_Scheduler, + float new_param, + int new_count, + ACE_Future<float> &new_result) + : scheduler_ (new_Scheduler), + param_ (new_param), + count_ (new_count), + future_result_ (new_result) +{ +} + +Method_Object_work::~Method_Object_work (void) +{ +} + +int +Method_Object_work::call (void) +{ + return this->future_result_.set (this->scheduler_->work_i (this->param_, this->count_)); +} + +class Method_Object_name : public ACE_Method_Object + // = TITLE + // Reification of the <name> method. +{ +public: + Method_Object_name (Scheduler *, ACE_Future<char*> &); + ~Method_Object_name (void); + virtual int call (void); + +private: + Scheduler *scheduler_; + ACE_Future<char*> future_result_; +}; + + +Method_Object_name::Method_Object_name (Scheduler *new_scheduler, + ACE_Future<char*> &new_result) + : scheduler_ (new_scheduler), + future_result_ (new_result) +{ + ACE_DEBUG ((LM_DEBUG, + " (%t) Method_Object_name created\n")); +}; + +Method_Object_name::~Method_Object_name (void) +{ + ACE_DEBUG ((LM_DEBUG, + " (%t) Method_Object_name will be deleted.\n")); +} + +int +Method_Object_name::call (void) +{ + return future_result_.set (scheduler_->name_i ()); +} + +class Method_Object_end : public ACE_Method_Object + // = TITLE + // Reification of the <end> method. +{ +public: + Method_Object_end (Scheduler *new_Scheduler): scheduler_ (new_Scheduler) {} + ~Method_Object_end (void) {} + virtual int call (void) { this->scheduler_->close (); return -1; } + +private: + Scheduler *scheduler_; +}; + +// constructor +Scheduler::Scheduler (const char *newname, Scheduler *new_Scheduler) +{ + ACE_NEW (this->name_, char[ACE_OS::strlen (newname) + 1]); + ACE_OS::strcpy ((char *) this->name_, newname); + this->scheduler_ = new_Scheduler; + ACE_DEBUG ((LM_DEBUG, " (%t) Scheduler %s created\n", this->name_)); +} + +// Destructor +Scheduler::~Scheduler (void) +{ + ACE_DEBUG ((LM_DEBUG, " (%t) Scheduler %s will be destroyed\n", this->name_)); +} + +int +Scheduler::open (void *args) +{ + scheduler_open_count++; + ACE_DEBUG ((LM_DEBUG, " (%t) Scheduler %s open\n", this->name_)); + return this->activate (THR_BOUND); +} + +int +Scheduler::close (u_long flags) +{ + ACE_DEBUG ((LM_DEBUG, " (%t) Scheduler %s close\n", this->name_)); + scheduler_open_count--; + return 0; +} + +int +Scheduler::svc (void) +{ + // Main event loop for this active object. + for (;;) + { + // Dequeue the next method object (we use an auto pointer in + // case an exception is thrown in the <call>). + auto_ptr<ACE_Method_Object> mo (this->activation_queue_.dequeue ()); + + ACE_DEBUG ((LM_DEBUG, " (%t) calling method object\n")); + // Call it. + if (mo->call () == -1) + break; + // Smart pointer destructor automatically deletes mo. + } + + /* NOTREACHED */ + return 0; +} + +void +Scheduler::end (void) +{ + this->activation_queue_.enqueue (new Method_Object_end (this)); +} + +// Here's where the Work takes place. +float +Scheduler::work_i (float param, + int count) +{ + float x = 0, y = 0; + + for (int j = 0; j < count; j++) + { + x = x + param; + y = y + ::sin (x); + } + + return y; +} + +char * +Scheduler::name_i (void) +{ + char *the_name; + + the_name = new char[ACE_OS::strlen (this->name_) + 1]; + ACE_OS::strcpy (the_name, this->name_); + + return the_name; +} + +ACE_Future<char *> +Scheduler::name (void) +{ + if (this->scheduler_) + // Delegate to the other scheduler + return this->scheduler_->name (); + else + { + ACE_Future<char*> new_future; + + if (this->thr_count () == 0) + { + // This scheduler is inactive... so we execute the user + // request right away... + + auto_ptr<ACE_Method_Object> mo (new Method_Object_name (this, new_future)); + + mo->call (); + // Smart pointer destructor automatically deletes mo. + } + else + // @@ What happens if new fails here? + this->activation_queue_.enqueue + (new Method_Object_name (this, new_future)); + + return new_future; + } +} + +ACE_Future<float> +Scheduler::work (float newparam, int newcount) +{ + if (this->scheduler_) + return this->scheduler_->work (newparam, newcount); + else + { + ACE_Future<float> new_future; + + if (this->thr_count () == 0) + { + auto_ptr<ACE_Method_Object> mo + (new Method_Object_work (this, newparam, newcount, new_future)); + mo->call (); + // Smart pointer destructor automatically deletes it. + } + else + this->activation_queue_.enqueue + (new Method_Object_work (this, newparam, newcount, new_future)); + + return new_future; + } +} + +static int +determine_iterations (void) +{ + int n_iterations; + + ACE_DEBUG ((LM_DEBUG," (%t) determining the number of iterations...\n")); + Scheduler *worker_a = new Scheduler ("worker A"); + + ACE_Time_Value tstart (ACE_OS::gettimeofday ()); + ACE_Time_Value tend (ACE_OS::gettimeofday ()); + + // Determine the number of iterations... we want so many that the + // work () takes about 1 second... + + for (n_iterations = 1; + (tend.sec () - tstart.sec ()) < 1; + n_iterations *= 2) + { + tstart = ACE_OS::gettimeofday (); + + worker_a->work (0.1, n_iterations); + + tend = ACE_OS::gettimeofday (); + } + + ACE_DEBUG ((LM_DEBUG," (%t) n_iterations %d\n", + (u_long) n_iterations)); + + worker_a->end (); + // @@ Can we safely delete worker_a here? + return n_iterations; +} + +static void +test_active_object (int n_iterations) +{ + ACE_DEBUG ((LM_DEBUG," (%t) testing active object pattern...\n")); + // A simple example for the use of the active object pattern and + // futures to return values from an active object. + + Scheduler *worker_a = new Scheduler ("worker A"); + Scheduler *worker_b = new Scheduler ("worker B"); + + // Have worker_c delegate his work to worker_a. + Scheduler *worker_c = new Scheduler ("worker C", worker_a); + + // loop 0: + // test the Schedulers when they are not active. + // now the method objects will be created but since + // there is no active thread they will also be + // immediately executed, in the "main" thread. + // loop 1: + // do the same test but with the schedulers + // activated + for (int i = 0; i < 2; i++) + { + if (i == 1) + { + worker_a->open (); + worker_b->open (); + worker_c->open (); + } + + ACE_Future<float> fresulta = worker_a->work (0.01, n_iterations); + ACE_Future<float> fresultb = worker_b->work (0.02, n_iterations); + ACE_Future<float> fresultc = worker_c->work (0.03, n_iterations); + + if (i == 0) + { + if (!fresulta.ready ()) + ACE_DEBUG ((LM_DEBUG," (%t) ERROR: worker A is should be ready!!!\n")); + if (!fresultb.ready ()) + ACE_DEBUG ((LM_DEBUG," (%t) ERROR: worker B is should be ready!!!\n")); + if (!fresultc.ready ()) + ACE_DEBUG ((LM_DEBUG," (%t) ERROR: worker C is should be ready!!!\n")); + } + + // When the workers are active we will block here until the + // results are available. + + float resulta = fresulta; + float resultb = fresultb; + float resultc = fresultc; + + ACE_Future<char *> fnamea = worker_a->name (); + ACE_Future<char *> fnameb = worker_b->name (); + ACE_Future<char *> fnamec = worker_c->name (); + + char *namea = fnamea; + char *nameb = fnameb; + char *namec = fnamec; + + ACE_DEBUG ((LM_DEBUG, " (%t) result from %s %f\n", + namea, resulta)); + ACE_DEBUG ((LM_DEBUG, " (%t) result from %s %f\n", + nameb, resultb)); + ACE_DEBUG ((LM_DEBUG, " (%t) result from %s %f\n", + namec, resultc)); + } + + ACE_DEBUG ((LM_DEBUG, " (%t) scheduler_open_count %d before end ()\n", + (u_long) scheduler_open_count)); + + worker_a->end (); + worker_b->end (); + worker_c->end (); + + ACE_DEBUG ((LM_DEBUG, " (%t) scheduler_open_count %d immediately after end ()\n", + (u_long) scheduler_open_count)); + + ACE_OS::sleep (2); + + ACE_DEBUG ((LM_DEBUG, " (%t) scheduler_open_count %d after waiting\n", + (u_long) scheduler_open_count)); + // @@ Can we safely delete worker_a, worker_b, and worker_c? +} + +static void +test_cancellation (int n_iterations) +{ + ACE_DEBUG ((LM_DEBUG," (%t) testing cancellation of a future...\n")); + + // Now test the cancelling a future. + + Scheduler *worker_a = new Scheduler ("worker A"); + worker_a->open (); + + ACE_Future<float> fresulta = worker_a->work (0.01, n_iterations); + + // save the result by copying the future + ACE_Future<float> fresultb = fresulta; + + // now we cancel the first future.. but the + // calculation will still go on... + fresulta.cancel (10.0); + + if (!fresulta.ready ()) + ACE_DEBUG ((LM_DEBUG," (%t) ERROR: future A is should be ready!!!\n")); + + float resulta = fresulta; + + ACE_DEBUG ((LM_DEBUG, " (%t) cancelled result %f\n", resulta)); + + if (resulta != 10.0) + ACE_DEBUG ((LM_DEBUG, " (%t) cancelled result should be 10.0!!\n", resulta)); + + resulta = fresultb; + + ACE_DEBUG ((LM_DEBUG, " (%t) true result %f\n", resulta)); + + worker_a->end (); + // @@ Can we safely delete worker_a here? +} + +static void +test_timeout (int n_iterations) +{ + ACE_DEBUG ((LM_DEBUG," (%t) testing timeout on waiting for the result...\n")); + Scheduler *worker_a = new Scheduler ("worker A"); + worker_a->open (); + + ACE_Future<float> fresulta = worker_a->work (0.01, 2 * n_iterations); + + // Should immediately return... and we should see an error... + ACE_Time_Value *delay = new ACE_Time_Value (1); + + float resulta; + fresulta.get (resulta, delay); + + if (fresulta.ready ()) + ACE_DEBUG ((LM_DEBUG," (%t) ERROR: future A is should not be ready!!!\n")); + else + ACE_DEBUG ((LM_DEBUG," (%t) timed out on future A\n")); + + // now we wait until we are done... + fresulta.get (resulta); + ACE_DEBUG ((LM_DEBUG, " (%t) result %f\n", resulta)); + + worker_a->end (); + // @@ Can we safely delete worker_a here? +} + +int +main (int argc, char *argv[]) +{ + int n_iterations = determine_iterations (); + + test_active_object (n_iterations); + test_cancellation (n_iterations); + test_timeout (n_iterations); + + ACE_DEBUG ((LM_DEBUG," (%t) that's all folks!\n")); + + ACE_OS::sleep (5); + return 0; +} + +#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +template class ACE_Atomic_Op<ACE_Thread_Mutex, u_long>; +#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ + +#else +int +main (int, char *[]) +{ + ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); + return 0; +} +#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_manual_event.cpp b/examples/Threads/test_manual_event.cpp new file mode 100644 index 00000000000..51612d1fcab --- /dev/null +++ b/examples/Threads/test_manual_event.cpp @@ -0,0 +1,99 @@ +// The test shows the use of an ACE_Manual_Event to create a +// @(#)test_manual_event.cpp 1.1 10/18/96 + +// Pseudo_Barrier. Multiple threads are created which do the +// following: +// +// 1. work +// 2. synch with other threads +// 3. more work +// +// ACE_Manual_Event is use to synch with other +// threads. ACE_Manual_Event::signal() is used for broadcasting. + +#include "ace/Service_Config.h" +#include "ace/Synch.h" +#include "ace/Thread_Manager.h" + +static ACE_Atomic_Op <ACE_Thread_Mutex, u_long> amount_of_work = (u_long) 0; + +class Pseudo_Barrier + // = TITLE + // A barrier class using ACE manual-reset events. + // + // = DESCRIPTION + // This is *not* a real barrier. + // Pseudo_Barrier is more like a ``one shot'' barrier. + // All waiters after the Nth waiter are allowed to go. + // The barrier does not reset after the Nth waiter. + // For an example of a real barrier, please see class ACE_Barrier. +{ +public: + Pseudo_Barrier (u_long count); + + int wait (void); + +private: + ACE_Atomic_Op <ACE_Thread_Mutex, u_long> counter_; + ACE_Manual_Event event_; +}; + +Pseudo_Barrier::Pseudo_Barrier (u_long count) + : counter_ (count) +{ +} + +int +Pseudo_Barrier::wait (void) +{ + if (--this->counter_ == 0) + return this->event_.signal (); + else + return this->event_.wait (); +} + +static void * +worker (void *arg) +{ + ACE_Thread_Control tc (ACE_Service_Config::thr_mgr ()); + Pseudo_Barrier &barrier = *(Pseudo_Barrier *) arg; + + // work + ACE_DEBUG ((LM_DEBUG, "(%t) working (%d secs)\n", ++::amount_of_work)); + ACE_OS::sleep (::amount_of_work); + + // synch with everybody else + ACE_DEBUG ((LM_DEBUG, "(%t) waiting to synch with others \n")); + barrier.wait (); + + // more work + ACE_DEBUG ((LM_DEBUG, "(%t) more work (%d secs)\n", ++::amount_of_work)); + ACE_OS::sleep (amount_of_work); + + ACE_DEBUG ((LM_DEBUG, "(%t) dying \n")); + + return 0; +} + +int +main (int argc, char **argv) +{ + int n_threads = argc == 2 ? atoi (argv[1]) : 5; + + ACE_Thread_Manager &tm = *ACE_Service_Config::thr_mgr (); + + // synch object shared by all threads + Pseudo_Barrier barrier (n_threads); + + // create workers + if (tm.spawn_n (n_threads, worker, &barrier) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "thread creates for worker failed"), -1); + + // wait for all workers to exit + if (tm.wait () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "thread wait failed"), -1); + else + ACE_DEBUG ((LM_ERROR, "graceful exit\n")); + + return 0; +} diff --git a/examples/Threads/test_process_mutex.cpp b/examples/Threads/test_process_mutex.cpp new file mode 100644 index 00000000000..1978e3601f0 --- /dev/null +++ b/examples/Threads/test_process_mutex.cpp @@ -0,0 +1,66 @@ +// This program tests ACE_Process_Mutexes. To run it, open 3 +// @(#)test_process_mutex.cpp 1.1 10/18/96 + +// or 4 windows and run this program in each window... + +#include "ace/Log_Msg.h" +#include "ace/Synch.h" +#include "ace/Signal.h" + +#if defined (ACE_HAS_THREADS) + +static sig_atomic_t done; + +static void +handler (int) +{ + done = 1; +} + +int +main (int argc, char *argv[]) +{ + char *name = argc == 1 ? "hello" : argv[1]; + + ACE_Process_Mutex pm (name); + ACE_Sig_Action handle ((ACE_SignalHandler) handler, SIGINT); + + for (int i = 0; i < 100 && !done; i++) + { + ACE_DEBUG ((LM_DEBUG, "(%P|%t) = acquiring\n")); + if (pm.acquire () == -1) + ACE_DEBUG ((LM_DEBUG, "(%P|%t) = %p\n", "acquire failed")); + else + ACE_DEBUG ((LM_DEBUG, "(%P|%t) = acquired\n")); + + ACE_OS::sleep (3); + + if (pm.release () == -1) + ACE_DEBUG ((LM_DEBUG, "(%P|%t) = %p\n", "release failed")); + else + ACE_DEBUG ((LM_DEBUG, "(%P|%t) = released\n")); + + if (pm.tryacquire () == -1) + ACE_DEBUG ((LM_DEBUG, "(%P|%t) = %p\n", "tryacquire failed")); + else + ACE_DEBUG ((LM_DEBUG, "(%P|%t) = tryacquire\n")); + + if (pm.release () == -1) + ACE_DEBUG ((LM_DEBUG, "(%P|%t) = %p\n", "release failed")); + else + ACE_DEBUG ((LM_DEBUG, "(%P|%t) = released\n")); + } + + if (argc > 2) + pm.remove (); + return 0; +} +#else +int +main (void) +{ + ACE_ERROR_RETURN ((LM_ERROR, + "ACE doesn't support support threads on this platform (yet)\n"), + -1); +} +#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_process_semaphore.cpp b/examples/Threads/test_process_semaphore.cpp new file mode 100644 index 00000000000..ed9831ab627 --- /dev/null +++ b/examples/Threads/test_process_semaphore.cpp @@ -0,0 +1,56 @@ +// This program tests ACE_Process_Semaphore. To run it, open 3 +// @(#)test_process_semaphore.cpp 1.1 10/18/96 + +// or 4 windows and run this program in each window... + +#include "ace/Log_Msg.h" +#include "ace/Synch.h" +#include "ace/Signal.h" + +static sig_atomic_t done; + +static void +handler (int) +{ + done = 1; +} + +int +main (int argc, char *argv[]) +{ + char *name = argc == 1 ? "hello" : argv[1]; + + ACE_Process_Semaphore pm (1, name); + + ACE_Sig_Action handle ((ACE_SignalHandler) handler, SIGINT); + + for (int i = 0; i < 100 && !done; i++) + { + ACE_DEBUG ((LM_DEBUG, "(%P|%t) = acquiring\n")); + if (pm.acquire () == -1) + ACE_DEBUG ((LM_DEBUG, "(%P|%t) = %p\n", "acquire failed")); + else + ACE_DEBUG ((LM_DEBUG, "(%P|%t) = acquired\n")); + + ACE_OS::sleep (3); + + if (pm.release () == -1) + ACE_DEBUG ((LM_DEBUG, "(%P|%t) = %p\n", "release failed")); + else + ACE_DEBUG ((LM_DEBUG, "(%P|%t) = released\n")); + + if (pm.tryacquire () == -1) + ACE_DEBUG ((LM_DEBUG, "(%P|%t) = %p\n", "tryacquire failed")); + else + ACE_DEBUG ((LM_DEBUG, "(%P|%t) = tryacquire\n")); + + if (pm.release () == -1) + ACE_DEBUG ((LM_DEBUG, "(%P|%t) = %p\n", "release failed")); + else + ACE_DEBUG ((LM_DEBUG, "(%P|%t) = released\n")); + } + + if (argc > 2) + pm.remove (); + return 0; +} diff --git a/examples/Threads/test_reader_writer.cpp b/examples/Threads/test_reader_writer.cpp new file mode 100644 index 00000000000..33d3e982bc6 --- /dev/null +++ b/examples/Threads/test_reader_writer.cpp @@ -0,0 +1,187 @@ +// This test program verifies the functionality of the ACE_OS +// @(#)test_reader_writer.cpp 1.1 10/18/96 + +// implementation of readers/writer locks on Win32 and Posix pthreads. + +#include "ace/Log_Msg.h" +#include "ace/Synch.h" +#include "ace/Thread.h" +#include "ace/Thread_Manager.h" +#include "ace/Get_Opt.h" + +#if defined (ACE_HAS_THREADS) + +// Default number of iterations. +static size_t n_iterations = 1000; + +// Default number of loops. +static size_t n_loops = 100; + +// Default number of readers. +static size_t n_readers = 6; + +// Default number of writers. +static size_t n_writers = 2; + +// Thread id of last writer. +volatile static int shared_data; + +// Lock for shared_data. +static ACE_RW_Mutex rw_mutex; + +// Count of the number of readers and writers. +ACE_Atomic_Op<ACE_Thread_Mutex, int> current_readers, current_writers; + +// Thread manager +static ACE_Thread_Manager thr_mgr; + +// Explain usage and exit. +static void +print_usage_and_die (void) +{ + ACE_DEBUG ((LM_DEBUG, + "usage: %n [-r n_readers] [-w n_writers] [-n iteration_count]\n")); + ACE_OS::exit (1); +} + +// Parse the command-line arguments and set options. +static void +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opt (argc, argv, "r:w:n:l:"); + + int c; + + while ((c = get_opt ()) != -1) + switch (c) + { + case 'r': + n_readers = ACE_OS::atoi (get_opt.optarg); + break; + case 'w': + n_writers = ACE_OS::atoi (get_opt.optarg); + break; + case 'n': + n_iterations = ACE_OS::atoi (get_opt.optarg); + break; + case 'l': + n_loops = ACE_OS::atoi (get_opt.optarg); + break; + default: + print_usage_and_die (); + break; + } +} + +// Iterate <n_iterations> each time checking that nobody modifies the data +// while we have a read lock. + +static void * +reader (void *) +{ + ACE_Thread_Control tc (&thr_mgr); + ACE_DEBUG ((LM_DEBUG, "(%t) reader starting\n")); + + for (int iterations = 1; iterations <= n_iterations; iterations++) + { + ACE_Read_Guard<ACE_RW_Mutex> g(rw_mutex); + int n = ++current_readers; + //ACE_DEBUG ((LM_DEBUG, "(%t) I'm reader number %d\n", n)); + + if (current_writers > 0) + ACE_DEBUG ((LM_DEBUG, "(%t) writers found!!!\n")); + + int data = shared_data; + + for (int loop = 1; loop <= n_loops; loop++) + { + ACE_Thread::yield(); + if (shared_data != data) + ACE_DEBUG ((LM_DEBUG, + "(%t) somebody changed %d to %d\n", + data, shared_data)); + } + + --current_readers; + //ACE_DEBUG ((LM_DEBUG, "(%t) done with reading guarded data\n")); + + ACE_Thread::yield (); + } + return 0; +} + +// Iterate <n_iterations> each time modifying the global data +// and checking that nobody steps on it while we can write it. + +static void * +writer (void *) +{ + ACE_Thread_Control tc (&thr_mgr); + ACE_DEBUG ((LM_DEBUG, "(%t) writer starting\n")); + + for (int iterations = 1; iterations <= n_iterations; iterations++) + { + ACE_Write_Guard<ACE_RW_Mutex> g(rw_mutex); + + ++current_writers; + //ACE_DEBUG ((LM_DEBUG, "(%t) writing to guarded data\n")); + + if (current_writers > 1) + ACE_DEBUG ((LM_DEBUG, "(%t) other writers found!!!\n")); + + if (current_readers > 0) + ACE_DEBUG ((LM_DEBUG, "(%t) readers found!!!\n")); + + int self = (int) ACE_Thread::self (); + shared_data = self; + + for (int loop = 1; loop <= n_loops; loop++) + { + ACE_Thread::yield(); + if (shared_data != self) + ACE_DEBUG ((LM_DEBUG, "(%t) somebody wrote on my data %d\n", shared_data)); + } + + --current_writers; + + //ACE_DEBUG ((LM_DEBUG, "(%t) done with guarded data\n")); + ACE_Thread::yield (); + } + return 0; +} + +// Spawn off threads. + +int main (int argc, char *argv[]) +{ + ACE_LOG_MSG->open (argv[0]); + parse_args (argc, argv); + + current_readers = 0; // Possibly already done + current_writers = 0; // Possibly already done + + ACE_DEBUG ((LM_DEBUG, "(%t) main thread starting\n")); + + if (thr_mgr.spawn_n (n_readers, reader, 0, THR_NEW_LWP) == -1 || + thr_mgr.spawn_n (n_writers, writer, 0, THR_NEW_LWP) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn_n"), 1); + + thr_mgr.wait (); + + ACE_DEBUG ((LM_DEBUG, "(%t) exiting main thread\n")); + return 0; +} + +#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +template class ACE_Atomic_Op<ACE_Thread_Mutex, int>; +#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ + +#else +int +main (int, char *[]) +{ + ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); + return 0; +} +#endif /* ACE_HAS_THREADS */ + diff --git a/examples/Threads/test_recursive_mutex.cpp b/examples/Threads/test_recursive_mutex.cpp new file mode 100644 index 00000000000..e1c0b8353e9 --- /dev/null +++ b/examples/Threads/test_recursive_mutex.cpp @@ -0,0 +1,110 @@ +// This test program verifies the functionality of the ACE_OS +// @(#)test_recursive_mutex.cpp 1.1 10/18/96 + +// implementation of recursive mutexes on Win32 and Posix pthreads. + +#include "ace/Log_Msg.h" + +#if defined (ACE_HAS_THREADS) + +#include "ace/Service_Config.h" +#include "ace/Get_Opt.h" +#include "ace/Synch.h" + +// Total number of iterations. +static size_t n_iterations = 1000; +static size_t n_threads = 4; + +// Explain usage and exit. +static void +print_usage_and_die (void) +{ + ACE_DEBUG ((LM_DEBUG, + "usage: %n [-t n_threads] [-n iteration_count]\n")); + ACE_OS::exit (1); +} + +// Parse the command-line arguments and set options. + +static void +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opt (argc, argv, "n:t:"); + + int c; + + while ((c = get_opt ()) != -1) + switch (c) + { + case 'n': + n_iterations = ACE_OS::atoi (get_opt.optarg); + break; + case 't': + n_threads = ACE_OS::atoi (get_opt.optarg); + break; + default: + print_usage_and_die (); + break; + } +} + +static void +recursive_worker (size_t nesting_level, + ACE_Recursive_Thread_Mutex *rm) +{ + if (nesting_level < n_iterations) + { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) = trying to acquire, nesting = %d, thread id = %u\n", + rm->get_nesting_level (), rm->get_thread_id ())); + { + // This illustrates the use of the ACE_Guard<LOCK> with an + // ACE_Recursive_Thread_Mutex. + ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon, *rm); + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) = acquired, nesting = %d, thread id = %u\n", + rm->get_nesting_level (), rm->get_thread_id ())); + + recursive_worker (nesting_level + 1, rm); + } + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) = released, nesting = %d, thread id = %u\n", + rm->get_nesting_level (), rm->get_thread_id ())); + } +} + +static void * +worker (void *arg) +{ + ACE_Thread_Control tc (ACE_Service_Config::thr_mgr ()); + + ACE_Recursive_Thread_Mutex *rm = (ACE_Recursive_Thread_Mutex *) arg; + + recursive_worker (0, rm); + return 0; +} + +int +main (int argc, char *argv[]) +{ + ACE_Service_Config daemon (argv[0]); + + parse_args (argc, argv); + ACE_Recursive_Thread_Mutex rm; + + ACE_Service_Config::thr_mgr ()->spawn_n (n_threads, + ACE_THR_FUNC (worker), + (void *) &rm); + + ACE_Service_Config::thr_mgr ()->wait (); + return 0; +} +#else +int +main (void) +{ + ACE_ERROR_RETURN ((LM_ERROR, + "ACE doesn't support support process mutexes on this platform (yet)\n"), + -1); +} +#endif /* ACE_WIN32 */ diff --git a/examples/Threads/test_task.cpp b/examples/Threads/test_task.cpp new file mode 100644 index 00000000000..d0e8e124ead --- /dev/null +++ b/examples/Threads/test_task.cpp @@ -0,0 +1,104 @@ +// This test program illustrates how the ACE barrier synchronization +// @(#)test_task.cpp 1.1 10/18/96 + +// mechanisms work in conjunction with the ACE_Task and the +// ACE_Thread_Manager. It is instructive to compare this with the +// test_barrier.cpp test to see how they differ. + +#include "ace/Task.h" +#include "ace/Service_Config.h" +#include "ace/Log_Msg.h" + +#if defined (ACE_HAS_THREADS) + +#include "ace/Task.h" + +class Barrier_Task : public ACE_Task<ACE_MT_SYNCH> +{ +public: + Barrier_Task (ACE_Thread_Manager *thr_mgr, + int n_threads, + int n_iterations); + + virtual int svc (void); + // Iterate <n_iterations> time printing off a message and "waiting" + // for all other threads to complete this iteration. + +private: + ACE_Barrier barrier_; + // Reference to the tester barrier. This controls each + // iteration of the tester function running in every thread. + + int n_iterations_; + // Number of iterations to run. + + // = Not needed for this test. + virtual int open (void *) { return 0; } + virtual int close (u_long) { return 0; } + virtual int put (ACE_Message_Block *, ACE_Time_Value *) { return 0; } +}; + +Barrier_Task::Barrier_Task (ACE_Thread_Manager *thr_mgr, + int n_threads, + int n_iterations) + : ACE_Task<ACE_MT_SYNCH> (thr_mgr), + barrier_ (n_threads), + n_iterations_ (n_iterations) +{ + // Create worker threads. + if (this->activate (THR_NEW_LWP, n_threads) == -1) + ACE_ERROR ((LM_ERROR, "%p\n", "activate failed")); +} + +// Iterate <n_iterations> time printing off a message and "waiting" +// for all other threads to complete this iteration. + +int +Barrier_Task::svc (void) +{ + // Note that the ACE_Task::svc_run() method automatically adds us to + // the Thread_Manager when the thread begins. + + for (int iterations = 1; + iterations <= this->n_iterations_; + iterations++) + { + ACE_DEBUG ((LM_DEBUG, "(%t) in iteration %d\n", iterations)); + + // Block until all other threads have waited, then continue. + this->barrier_.wait (); + } + + // Note that the ACE_Task::svc_run() method automatically removes us + // from the Thread_Manager when the thread exits. + + return 0; +} + +// Default number of threads to spawn. +static const int DEFAULT_ITERATIONS = 5; + +int +main (int argc, char *argv[]) +{ + int n_threads = argc > 1 ? ACE_OS::atoi (argv[1]) : ACE_DEFAULT_THREADS; + int n_iterations = argc > 2 ? ACE_OS::atoi (argv[2]) : DEFAULT_ITERATIONS; + + Barrier_Task barrier_task (ACE_Service_Config::thr_mgr (), + n_threads, + n_iterations); + + // Wait for all the threads to reach their exit point. + ACE_Service_Config::thr_mgr ()->wait (); + + ACE_DEBUG ((LM_DEBUG, "(%t) done\n")); + return 0; +} +#else +int +main (int, char *[]) +{ + ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); + return 0; +} +#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_task_three.cpp b/examples/Threads/test_task_three.cpp new file mode 100644 index 00000000000..348d8b0b7d0 --- /dev/null +++ b/examples/Threads/test_task_three.cpp @@ -0,0 +1,229 @@ +// Exercise more tests for the ACE Tasks. This also shows off some +// @(#)test_task_three.cpp 1.1 10/18/96 + +// interesting uses of the ACE Log_Msg's ability to print to ostreams. +// BTW, make sure that you set the out_stream in *every* thread that +// you want to have write to the output file, i.e.: +// +// +// if (out_stream) +// { +// ACE_LOG_MSG->set_flags (ACE_Log_Msg::OSTREAM); +// ACE_LOG_MSG->msg_ostream (out_stream); +// } + +#include <fstream.h> +#include "ace/Reactor.h" +#include "ace/Service_Config.h" +#include "ace/Task.h" +#include "ace/Log_Msg.h" + +#if defined (ACE_HAS_THREADS) + +static ofstream *out_stream = 0; + +static const int NUM_INVOCATIONS = 100; +static const int TASK_COUNT = 130; + +class Test_Task : public ACE_Task<ACE_MT_SYNCH> +{ +public: + Test_Task (void); + ~Test_Task (void); + + virtual int open (void *args = 0); + virtual int close (u_long flags = 0); + virtual int put (ACE_Message_Block *, ACE_Time_Value *tv = 0); + virtual int svc (void); + + virtual int handle_input (ACE_HANDLE fd); + + ACE_Reactor *r_; + int handled_; + static int current_count_; + static int done_cnt_; +}; + +int Test_Task::current_count_ = 0; +int Test_Task::done_cnt_ = 0; + +static ACE_Thread_Mutex lock_; + +Test_Task::Test_Task (void) +{ + ACE_GUARD (ACE_Thread_Mutex, ace_mon, lock_); + + this->handled_ = 0; + Test_Task::current_count_++; + ACE_DEBUG ((LM_DEBUG, + "Test_Task constructed, current_count_ = %d\n", + Test_Task::current_count_)); +} + +Test_Task::~Test_Task (void) +{ + ACE_GUARD (ACE_Thread_Mutex, ace_mon, lock_); + + ACE_DEBUG ((LM_DEBUG, "Test_Task destroyed, current_count_ = %d\n", + Test_Task::current_count_)); +} + +int +Test_Task::open (void *args) +{ + r_ = (ACE_Reactor *) args; + return ACE_Task<ACE_MT_SYNCH>::activate (THR_NEW_LWP); +} + +int +Test_Task::close (u_long flags) +{ + ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, lock_, -1); + + Test_Task::current_count_--; + ACE_DEBUG ((LM_DEBUG, "Test_Task::close () current_count_ = %d.\n", + Test_Task::current_count_)); + return 0; +} + +int +Test_Task::put (ACE_Message_Block *mb, ACE_Time_Value *tv) +{ + return 0; +} + +int +Test_Task::svc (void) +{ + // Every thread must register the same stream to write to file. + if (out_stream) + { + ACE_LOG_MSG->set_flags (ACE_Log_Msg::OSTREAM); + ACE_LOG_MSG->msg_ostream (out_stream); + } + + for (int index = 0; index < NUM_INVOCATIONS; index++) + { + ACE_OS::thr_yield (); + + if (r_->notify (this, ACE_Event_Handler::READ_MASK)) + { + ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, lock_, -1); + + ACE_DEBUG ((LM_DEBUG, "Test_Task: error notifying reactor!\n")); + } + } + + ACE_DEBUG ((LM_DEBUG, " (%t) returning from svc ()\n")); + return 0; +} + +int +Test_Task::handle_input (ACE_HANDLE) +{ + this->handled_++; + + if (this->handled_ == NUM_INVOCATIONS) + { + ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, lock_, -1); + Test_Task::done_cnt_++; + ACE_DEBUG ((LM_DEBUG, + " (%t) Test_Task: handle_input! done_cnt_ = %d.\n", + Test_Task::done_cnt_)); + } + + ACE_OS::thr_yield (); + return -1; +} + +void * +dispatch (void *arg) +{ + // every thread must register the same stream to write to file + if (out_stream) + { + ACE_LOG_MSG->set_flags (ACE_Log_Msg::OSTREAM); + ACE_LOG_MSG->msg_ostream (out_stream); + } + + ACE_DEBUG ((LM_DEBUG, " (%t) Dispatcher Thread started!\n")); + ACE_Reactor *r = (ACE_Reactor *) arg; + int result; + + r->owner (ACE_OS::thr_self ()); + + while (1) + { + result = r->handle_events (); + if (result <= 0) + ACE_DEBUG ((LM_DEBUG, "Dispatch: handle_events (): %d", result)); + } + + return 0; +} + +static void +handler (int signum) +{ + *out_stream << flush; + out_stream->close (); + ACE_OS::exit (42); +} + +int +main (int argc, char **argv) +{ + if (argc > 1) + { + // Send output to file. + out_stream = new ofstream ("test_task_three.out", ios::trunc|ios::out); + ACE_LOG_MSG->set_flags (ACE_Log_Msg::OSTREAM); + ACE_LOG_MSG->msg_ostream (out_stream); + signal (SIGINT, ACE_SignalHandler (handler)); + } + + ACE_Reactor *reactor1 = ACE_Service_Config::reactor (); + ACE_Reactor *reactor2 = new ACE_Reactor (); + + Test_Task t1[TASK_COUNT]; + Test_Task t2[TASK_COUNT]; + + ACE_Thread::spawn (dispatch, reactor2); + + reactor1->owner (ACE_OS::thr_self ()); + + for (int index = 0; index < TASK_COUNT; index++) + { + t1[index].open (reactor1); + t2[index].open (reactor2); + } + + ACE_OS::sleep (3); + + for (;;) + { + ACE_Time_Value timeout (2); + + if (reactor1->handle_events (timeout) <= 0) + { + if (errno == ETIME) + { + ACE_DEBUG ((LM_DEBUG, "no activity within 2 seconds, shutting down\n")); + break; + } + else + ACE_ERROR ((LM_ERROR, "%p error handling events\n", "main")); + } + } + + return 0; +} + +#else +int +main (int, char *[]) +{ + ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); + return 0; +} +#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_task_two.cpp b/examples/Threads/test_task_two.cpp new file mode 100644 index 00000000000..4ce201a74bc --- /dev/null +++ b/examples/Threads/test_task_two.cpp @@ -0,0 +1,156 @@ +// Exercise more tests for the ACE Tasks. This test can spawn off +// @(#)test_task_two.cpp 1.1 10/18/96 + +// zillions of tasks and then wait for them using both polling and the +// ACE Thread Manager. + +#include "ace/Task.h" +#include "ace/Log_Msg.h" +#include "ace/Service_Config.h" +#include "ace/Synch.h" + +#if defined (ACE_HAS_THREADS) + +typedef ACE_Atomic_Op<ACE_Thread_Mutex, u_long> ATOMIC_INT; + +static u_long zero = 0; +static ATOMIC_INT task_count (zero); +static ATOMIC_INT max_count (zero); +static ATOMIC_INT wait_count (zero); + +static u_long n_threads = 0; + +// Default number of tasks. +static const int default_threads = ACE_DEFAULT_THREADS; + +// Default number of times to run the test. +static const int default_iterations = 1000; + +class Task_Test : public ACE_Task<ACE_MT_SYNCH> +{ +public: + virtual int open (void *args = 0); + virtual int close (u_long flags = 0); + virtual int put (ACE_Message_Block *, ACE_Time_Value *tv = 0); + virtual int svc (void); + +private: + static ACE_Thread_Mutex lock_; +}; + +ACE_Thread_Mutex Task_Test::lock_; + +int +Task_Test::open (void *args) +{ + ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, Task_Test::lock_, -1); + + task_count++; + ACE_DEBUG ((LM_DEBUG, "(%t) creating Task_Test, task count = %d\n", + (u_long) task_count)); + + return this->activate (THR_BOUND); +} + +int +Task_Test::close (u_long flags) +{ + ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, Task_Test::lock_, -1); + + task_count--; + ACE_DEBUG ((LM_DEBUG, "(%t) destroying Task_Test, task count = %d\n", + (u_long) task_count)); + wait_count--; +// delete this; + return 0; +} + +int +Task_Test::put (ACE_Message_Block *mb, + ACE_Time_Value *tv) +{ + return 0; +} + +int +Task_Test::svc (void) +{ + wait_count++; + max_count++; + + ACE_DEBUG ((LM_DEBUG, "(%t) svc: waiting\n")); + + for (;;) + if (max_count >= n_threads) + break; + else + ACE_Thread::yield (); + + ACE_DEBUG ((LM_DEBUG, "(%t) svc: finished waiting\n")); + return 0; +} + +int +main (int argc, char *argv[]) +{ + int n_threads = argc > 1 ? ACE_OS::atoi (argv[1]) : default_threads; + int n_iterations = argc > 2 ? ACE_OS::atoi (argv[2]) : default_iterations; + + Task_Test **task_array = new Task_Test *[n_threads]; + + for (int i = 1; i <= n_iterations; i++) + { + ACE_DEBUG ((LM_DEBUG, "(%t) iteration = %d, max_count %d\n", + i, (u_long) max_count)); + max_count = 0; + + ACE_DEBUG ((LM_DEBUG, "(%t) starting %d task%s\n", + n_threads, n_threads == 1 ? "" : "s")); + + // Launch the new tasks. + for (int j = 0; j < n_threads; j++) + { + task_array[j] = new Task_Test; + // Activate the task, i.e., make it an active object. + task_array[j]->open (); + } + + // Wait for initialization to kick in. + while (max_count == 0) + ACE_Thread::yield (); + + ACE_DEBUG ((LM_DEBUG, "(%t) waiting for threads to finish\n")); + + // Wait for the threads to finish this iteration. + while (max_count != n_threads && wait_count != 0) + ACE_Thread::yield (); + + ACE_DEBUG ((LM_DEBUG, "(%t) iteration %d finished, max_count %d, wait_count %d, waiting for tasks to exit\n", + i, (u_long) max_count, (u_long) wait_count)); + + // Wait for all the tasks to exit. + ACE_Service_Config::thr_mgr ()->wait (); + + // Delete the existing tasks. + for (int k = 0; k < n_threads; k++) + delete task_array[k]; + } + + delete [] task_array; + + ACE_DEBUG ((LM_DEBUG, "(%t) shutting down the test\n")); + return 0; +} + +#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +template class ACE_Atomic_Op<ACE_Thread_Mutex, u_long>; +#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ + +#else +int +main (int, char *[]) +{ + ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); + return 0; +} +#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_thread_manager.cpp b/examples/Threads/test_thread_manager.cpp new file mode 100644 index 00000000000..efa5a2cc2a6 --- /dev/null +++ b/examples/Threads/test_thread_manager.cpp @@ -0,0 +1,105 @@ +// Test out the group management mechanisms provided by the +// @(#)test_thread_manager.cpp 1.1 10/18/96 + +// ACE_Thread_Manager, including the group signal handling, group +// suspension and resumption, and cooperative thread cancellation +// mechanisms. + +#include "ace/Service_Config.h" +#include "ace/Thread_Manager.h" + +#if defined (ACE_HAS_THREADS) + +static void +handler (int signum) +{ + ACE_DEBUG ((LM_DEBUG, "(%t) received signal %d\n", signum)); +} + +static void * +worker (int iterations) +{ + ACE_Thread_Control tc (ACE_Service_Config::thr_mgr ()); + + for (int i = 0; i < iterations; i++) + { + if ((i % 1000) == 0) + { + ACE_DEBUG ((LM_DEBUG, + "(%t) checking cancellation before iteration %d!\n", + i)); + + if (ACE_Service_Config::thr_mgr ()->testcancel (ACE_Thread::self ()) != 0) + { + ACE_DEBUG ((LM_DEBUG, + "(%t) has been cancelled before iteration %d!\n", + i)); + break; + } + } + } + + // Destructor removes thread from Thread_Manager. + return 0; +} + +static const int DEFAULT_THREADS = ACE_DEFAULT_THREADS; +static const int DEFAULT_ITERATIONS = 100000; + +int +main (int argc, char *argv[]) +{ + ACE_Service_Config daemon; + + daemon.open (argv[0]); + + // Register a signal handler + ACE_SignalHandler sh (handler); + ACE_Sig_Action sa (sh, SIGINT); + + int n_threads = argc > 1 ? ACE_OS::atoi (argv[1]) : DEFAULT_THREADS; + int n_iterations = argc > 2 ? ACE_OS::atoi (argv[2]) : DEFAULT_ITERATIONS; + + ACE_Thread_Manager *thr_mgr = ACE_Service_Config::thr_mgr (); + + int grp_id = thr_mgr->spawn_n (n_threads, ACE_THR_FUNC (worker), + (void *) n_iterations, + THR_NEW_LWP | THR_DETACHED); + + // Wait for 1 second and then suspend every thread in the group. + ACE_OS::sleep (1); + ACE_DEBUG ((LM_DEBUG, "(%t) suspending group\n")); + if (thr_mgr->suspend_grp (grp_id) == -1) + ACE_ERROR ((LM_DEBUG, "(%t) %p\n", "suspend_grp")); + + // Wait for 1 more second and then resume every thread in the + // group. + ACE_OS::sleep (ACE_Time_Value (1)); + ACE_DEBUG ((LM_DEBUG, "(%t) resuming group\n")); + if (thr_mgr->resume_grp (grp_id) == -1) + ACE_ERROR ((LM_DEBUG, "(%t) %p\n", "resume_grp")); + + // Wait for 1 more second and then send a SIGINT to every thread in + // the group. + ACE_OS::sleep (ACE_Time_Value (1)); + ACE_DEBUG ((LM_DEBUG, "(%t) signaling group\n")); + if (thr_mgr->kill_grp (grp_id, SIGINT) == -1) + ACE_ERROR ((LM_DEBUG, "(%t) %p\n", "kill_grp")); + + // Wait for 1 more second and then cancel all the threads. + ACE_OS::sleep (ACE_Time_Value (1)); + ACE_DEBUG ((LM_DEBUG, "(%t) cancelling group\n")); + if (thr_mgr->cancel_grp (grp_id) == -1) + ACE_ERROR ((LM_DEBUG, "(%t) %p\n", "cancel_grp")); + + // Perform a barrier wait until all the threads have shut down. + thr_mgr->wait (); + return 0; +} +#else +int +main (int, char *[]) +{ + ACE_ERROR_RETURN ((LM_ERROR, "threads not supported on this platform\n"), -1); +} +#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_thread_pool.cpp b/examples/Threads/test_thread_pool.cpp new file mode 100644 index 00000000000..28892ed9356 --- /dev/null +++ b/examples/Threads/test_thread_pool.cpp @@ -0,0 +1,214 @@ +// This test program illustrates how the ACE task synchronization +// @(#)test_thread_pool.cpp 1.1 10/18/96 + +// mechanisms work in conjunction with the ACE_Task and the +// ACE_Thread_Manager. If the manual flag is not set input comes from +// stdin until the user enters a return only. This stops all workers +// via a message block of length 0. This is an alternative shutdown of +// workers compared to queue deactivate. +// +// This code is original based on a test program written by Karlheinz +// Dorn. It was modified to utilize more "ACE" features by Doug Schmidt. + +#include "ace/Task.h" +#include "ace/Service_Config.h" +#include "ace/Log_Msg.h" +#include "ace/Task.h" + +#if defined (ACE_HAS_THREADS) + +// Number of iterations to run the test. +static size_t n_iterations = 100; + +class Thread_Pool : public ACE_Task<ACE_MT_SYNCH> +{ +public: + Thread_Pool (ACE_Thread_Manager *thr_mgr, int n_threads); + + virtual int svc (void); + // Iterate <n_iterations> time printing off a message and "waiting" + // for all other threads to complete this iteration. + + virtual int put (ACE_Message_Block *mb, ACE_Time_Value *tv=0); + // This allows the producer to pass messages to the <Thread_Pool>. + +private: + virtual int close (u_long); + + // = Not needed for this test. + virtual int open (void *) { return 0; } +}; + +int +Thread_Pool::close (u_long) +{ + ACE_DEBUG ((LM_DEBUG, "(%t) close of worker\n")); + return 0; +} + +Thread_Pool::Thread_Pool (ACE_Thread_Manager *thr_mgr, + int n_threads) + : ACE_Task<ACE_MT_SYNCH> (thr_mgr) +{ + // Create worker threads. + if (this->activate (THR_NEW_LWP, n_threads) == -1) + ACE_ERROR ((LM_ERROR, "%p\n", "activate failed")); +} + +// Simply enqueue the Message_Block into the end of the queue. + +int +Thread_Pool::put (ACE_Message_Block *mb, ACE_Time_Value *tv) +{ + return this->putq (mb, tv); +} + +// Iterate <n_iterations> time printing off a message and "waiting" +// for all other threads to complete this iteration. + +int +Thread_Pool::svc (void) +{ + // Note that the ACE_Task::svc_run () method automatically adds us to + // the Thread_Manager when the thread begins. + + int result = 0; + int count = 1; + + // Keep looping, reading a message out of the queue, until we get a + // message with a length == 0, which signals us to quit. + + for (;; count++) + { + ACE_Message_Block *mb; + + ACE_DEBUG ((LM_DEBUG, "(%t) in iteration %d before getq ()\n", count)); + + if (this->getq (mb) == -1) + { + ACE_ERROR ((LM_ERROR, + "(%t) in iteration %d, got result -1, exiting\n", count)); + break; + } + + int length = mb->length (); + + if (length > 0) + ACE_DEBUG ((LM_DEBUG, + "(%t) in iteration %d, length = %d, text = \"%*s\"\n", + count, length, length - 1, mb->rd_ptr ())); + + // We're responsible for deallocating this. + delete mb; + + if (length == 0) + { + ACE_DEBUG ((LM_DEBUG, + "(%t) in iteration %d, got NULL message, exiting\n", + count)); + break; + } + } + + // Note that the ACE_Task::svc_run () method automatically removes + // us from the Thread_Manager when the thread exits. + return 0; +} + +static void +produce (Thread_Pool &thread_pool) +{ + ACE_DEBUG ((LM_DEBUG, "(%t) producer start, dumping the Thread_Pool\n")); + thread_pool.dump (); + + for (int n;;) + { + // Allocate a new message. + ACE_Message_Block *mb = new ACE_Message_Block (BUFSIZ); + +#if defined (manual) + ACE_DEBUG ((LM_DEBUG, + "(%t) press chars and enter to put a new message into task queue...")); + n = ACE_OS::read (ACE_STDIN, mb->rd_ptr (), mb->size ()); +#else // Automatically generate messages. + static int count = 0; + + ACE_OS::sprintf (mb->rd_ptr (), "%d\n", count); + + n = ACE_OS::strlen (mb->rd_ptr ()); + + if (count == n_iterations) + n = 1; // Indicate that we need to shut down. + else + count++; + + if (count == 0 || (count % 20 == 0)) + ACE_OS::sleep (1); +#endif /* manual */ + if (n > 1) + { + // Send a normal message to the waiting threads and continue + // producing. + mb->wr_ptr (n); + + // Pass the message to the Thread_Pool. + if (thread_pool.put (mb) == -1) + ACE_ERROR ((LM_ERROR, " (%t) %p\n", "put")); + } + else + { + // Send a shutdown message to the waiting threads and exit. + ACE_DEBUG ((LM_DEBUG, "\n(%t) start loop, dump of task:\n")); + thread_pool.dump (); + + for (int i = thread_pool.thr_count (); i > 0; i--) + { + ACE_DEBUG ((LM_DEBUG, + "(%t) EOF, enqueueing NULL block for thread = %d\n", + i)); + + // Enqueue a NULL message to flag each consumer to + // shutdown. + if (thread_pool.put (new ACE_Message_Block) == -1) + ACE_ERROR ((LM_ERROR, " (%t) %p\n", "put")); + } + + ACE_DEBUG ((LM_DEBUG, "\n(%t) end loop, dump of task:\n")); + thread_pool.dump (); + break; + } + } +} + +int +main (int argc, char *argv[]) +{ + int n_threads = argc > 1 ? ACE_OS::atoi (argv[1]) : ACE_DEFAULT_THREADS; + n_iterations = argc > 2 ? ACE_OS::atoi (argv[2]) : n_iterations; + + ACE_DEBUG ((LM_DEBUG, "(%t) argc = %d, threads = %d\n", + argc, n_threads)); + + // Create the worker tasks. + Thread_Pool thread_pool (ACE_Service_Config::thr_mgr (), + n_threads); + + // Create work for the worker tasks to process in their own threads. + produce (thread_pool); + + // Wait for all the threads to reach their exit point. + + ACE_DEBUG ((LM_DEBUG, "(%t) waiting with thread manager...\n")); + ACE_Service_Config::thr_mgr ()->wait (); + + ACE_DEBUG ((LM_DEBUG, "(%t) destroying worker tasks and exiting...\n")); + return 0; +} +#else +int +main (int, char *[]) +{ + ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); + return 0; +} +#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_thread_specific.cpp b/examples/Threads/test_thread_specific.cpp new file mode 100644 index 00000000000..ac0cc7ed5d1 --- /dev/null +++ b/examples/Threads/test_thread_specific.cpp @@ -0,0 +1,208 @@ +#include "ace/Service_Config.h" +// @(#)test_thread_specific.cpp 1.1 10/18/96 + +#include "ace/Synch.h" +#include "ace/Log_Msg.h" + +// Define a class that will be stored in thread-specific data. Note +// that as far as this class is concerned it's just a regular C++ +// class. The ACE_TSS wrapper transparently ensures that +// objects of this class will be placed in thread-specific storage. +// All calls on ACE_TSS::operator->() are delegated to the +// appropriate method in the Errno class. + +class Errno +{ +public: + int error (void) { return this->errno_; } + void error (int i) { this->errno_ = i; } + + int line (void) { return this->lineno_; } + void line (int l) { this->lineno_ = l; } + + // Errno::flags_ is a static variable, so we've got to protect it + // with a mutex since it isn't kept in thread-specific storage. + int flags (void) + { + ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, Errno::lock_, -1); + + return Errno::flags_; + } + + void flags (int f) + { + ACE_GUARD (ACE_Thread_Mutex, ace_mon, Errno::lock_); + + Errno::flags_ = f; + } + +private: + // = errno_ and lineno_ will be thread-specific data so they don't + // need a lock. + int errno_; + int lineno_; + + static int flags_; +#if defined (ACE_HAS_THREADS) + // flags_ needs a lock. + static ACE_Thread_Mutex lock_; +#endif /* ACE_HAS_THREADS */ +}; + +// Static variables. +ACE_MT (ACE_Thread_Mutex Errno::lock_); +int Errno::flags_; + +// This is our thread-specific error handler... +static ACE_TSS<Errno> TSS_Error; + +#if defined (ACE_HAS_THREADS) +// Serializes output via cout. +static ACE_Thread_Mutex lock; + +typedef ACE_TSS_Guard<ACE_Thread_Mutex> GUARD; +#else +// Serializes output via cout. +static ACE_Null_Mutex lock; + +typedef ACE_Guard<ACE_Null_Mutex> GUARD; +#endif /* ACE_HAS_THREADS */ + +static void +cleanup (void *ptr) +{ + ACE_DEBUG ((LM_DEBUG, "(%t) in cleanup, ptr = %x\n", ptr)); + + delete ptr; +} + +// This worker function is the entry point for each thread. + +static void * +worker (void *c) +{ + ACE_Thread_Control tc (ACE_Service_Config::thr_mgr ()); + int count = int (c); + + ACE_thread_key_t key = 0; + int *ip = 0; + + // Make one key that will be available when the thread exits so that + // we'll have something to cleanup! + + if (ACE_OS::thr_keycreate (&key, cleanup) == -1) + ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_keycreate")); + + ip = new int; + + if (ACE_OS::thr_setspecific (key, (void *) ip) == -1) + ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_setspecific")); + + for (int i = 0; i < count; i++) + { + if (ACE_OS::thr_keycreate (&key, cleanup) == -1) + ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_keycreate")); + + ip = new int; + + ACE_DEBUG ((LM_DEBUG, "(%t) in worker 1, key = %d, ip = %x\n", key, ip)); + + if (ACE_OS::thr_setspecific (key, (void *) ip) == -1) + ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_setspecific")); + + if (ACE_OS::thr_getspecific (key, (void **) &ip) == -1) + ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_setspecific")); + + if (ACE_OS::thr_setspecific (key, (void *) 0) == -1) + ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_setspecific")); + + delete ip; + + if (ACE_OS::thr_keyfree (key) == -1) + ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_keyfree")); + + // Cause an error. + ACE_OS::read (ACE_INVALID_HANDLE, 0, 0); + + // The following two lines set the thread-specific state. + TSS_Error->error (errno); + TSS_Error->line (__LINE__); + + // This sets the static state (note how C++ makes it easy to do + // both). + TSS_Error->flags (count); + + { + // Use the guard to serialize access to cout... + ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, lock, 0); + + cout << "(" << ACE_Thread::self () + << ") errno = " << TSS_Error->error () + << ", lineno = " << TSS_Error->line () + << ", flags = " << TSS_Error->flags () + << endl; + } + key = 0; + + if (ACE_OS::thr_keycreate (&key, cleanup) == -1) + ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_keycreate")); + + ip = new int; + + ACE_DEBUG ((LM_DEBUG, "(%t) in worker 2, key = %d, ip = %x\n", key, ip)); + + if (ACE_OS::thr_setspecific (key, (void *) ip) == -1) + ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_setspecific")); + + if (ACE_OS::thr_getspecific (key, (void **) &ip) == -1) + ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_setspecific")); + + if (ACE_OS::thr_setspecific (key, (void *) 0) == -1) + ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_setspecific")); + + delete ip; + + if (ACE_OS::thr_keyfree (key) == -1) + ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_keyfree")); + } + + ACE_DEBUG ((LM_DEBUG, "(%t) exiting\n")); + return 0; +} + +static void +handler (int signum) +{ + ACE_DEBUG ((LM_DEBUG, "signal = %S\n", signum)); + ACE_Service_Config::thr_mgr ()->exit (0); +} + +int +main (int argc, char *argv[]) +{ + // The Service_Config must *always* be the first object defined in + // main... + ACE_Service_Config daemon (argv[0]); + ACE_Thread_Control tc (ACE_Service_Config::thr_mgr ()); + int threads = argc > 1 ? ACE_OS::atoi (argv[1]) : 4; + int count = argc > 2 ? ACE_OS::atoi (argv[2]) : 10000; + + signal (SIGINT, ACE_SignalHandler (handler)); + +#if defined (ACE_HAS_THREADS) + if (ACE_Service_Config::thr_mgr ()->spawn_n (threads, + ACE_THR_FUNC (&worker), + (void *) count, + THR_BOUND | THR_DETACHED) == -1) + ACE_OS::perror ("ACE_Thread_Manager::spawn_n"); + + ACE_Service_Config::thr_mgr ()->wait (); +#else + worker ((void *) count); +#endif /* ACE_HAS_THREADS */ + return 0; +} + +#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +template class ACE_TSS<Errno>; +#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ diff --git a/examples/Threads/test_token.cpp b/examples/Threads/test_token.cpp new file mode 100644 index 00000000000..bd8d399102f --- /dev/null +++ b/examples/Threads/test_token.cpp @@ -0,0 +1,76 @@ +// Test out the ACE Token class. +// @(#)test_token.cpp 1.1 10/18/96 + +#include "ace/Token.h" +#include "ace/Task.h" + +#if defined (ACE_HAS_THREADS) + +class My_Task : public ACE_Task<ACE_MT_SYNCH> +{ +public: + My_Task (int n); + virtual int open (void *) { return 0; } + virtual int close (u_long) { return 0; } + virtual int put (ACE_Message_Block *, ACE_Time_Value *tv) { return 0; } + virtual int svc (void); + + static void sleep_hook (void *); + +private: + ACE_Token token_; +}; + +My_Task::My_Task (int n) +{ + // Make this Task into an Active Object. + this->activate (THR_BOUND | THR_DETACHED, n); + + // Wait for all the threads to exit. + this->thr_mgr ()->wait (); +} + +void +My_Task::sleep_hook (void *) +{ + cerr << '(' << ACE_Thread::self () << ')' + << " blocking, My_Task::sleep_hook () called" << endl; +} + +// Test out the behavior of the ACE_Token class. + +int +My_Task::svc (void) +{ + for (int i = 0; i < 10000; i++) + { + // Wait for up to 1 millisecond past the current time to get the token. + ACE_Time_Value timeout (ACE_OS::time (0), 1000); + + if (this->token_.acquire (&My_Task::sleep_hook, 0, &timeout) == 1) + { + this->token_.acquire (); + this->token_.renew (); + this->token_.release (); + this->token_.release (); + } + else + ACE_Thread::yield (); + } + return 0; +} + +int +main (int argc, char *argv[]) +{ + My_Task tasks (argc > 1 ? atoi (argv[1]) : 4); + + return 0; +} +#else +int +main (void) +{ + ACE_ERROR_RETURN ((LM_ERROR, "your platform doesn't support threads\n"), -1); +} +#endif /* */ diff --git a/examples/Threads/test_tss.cpp b/examples/Threads/test_tss.cpp new file mode 100644 index 00000000000..ed8cd32017e --- /dev/null +++ b/examples/Threads/test_tss.cpp @@ -0,0 +1,235 @@ +// Torture test ACE thread-specific storage... +// @(#)test_tss.cpp 1.1 10/18/96 + + +#include "ace/Task.h" +#include "ace/Token.h" + +#if defined (ACE_HAS_THREADS) + +class TSS_Obj +{ +public: + + TSS_Obj (void); + ~TSS_Obj (void); + +private: + static int count_; + static ACE_Thread_Mutex lock_; +}; + +int TSS_Obj::count_ = 0; +ACE_Thread_Mutex TSS_Obj::lock_; + +TSS_Obj::TSS_Obj (void) +{ + ACE_GUARD (ACE_Thread_Mutex, ace_mon, lock_); + + count_++; + cout << "TO+ : " << count_ << endl; +} + +TSS_Obj::~TSS_Obj (void) +{ + ACE_GUARD (ACE_Thread_Mutex, ace_mon, lock_); + + count_--; + cout << "TO- : " << count_ << endl; +} + +class Test_Task +{ +public: + + Test_Task (void); + ~Test_Task (void); + + int open (void *arg); + + static void* svc (void *arg); + + static int wait_count_; + static int max_count_; + +private: + static int count_; +}; + +int Test_Task::count_ = 0; +int Test_Task::wait_count_ = 0; +int Test_Task::max_count_ = 0; +int num_threads_ = 0; + +ACE_Token token; + +Test_Task::Test_Task (void) +{ + ACE_GUARD (ACE_Token, ace_mon, token); + + count_++; + cout << "Test_Task+ : " + << count_ << " (" + << ACE_OS::thr_self () + << ")" << endl; +} + +Test_Task::~Test_Task (void) +{ + ACE_GUARD (ACE_Token, ace_mon, token); + + count_--; + cout << "Test_Task- : " + << count_ << " (" + << ACE_OS::thr_self () + << ")" << endl; + + wait_count_--; +} + +int Test_Task::open (void *arg) +{ + + ACE_Thread::spawn (Test_Task::svc, arg); + + return 0; +} + + +void * +Test_Task::svc (void *arg) +{ + ACE_TSS<TSS_Obj> tss (new TSS_Obj); + + { + ACE_GUARD_RETURN (ACE_Token, ace_mon, token, 0); + + wait_count_++; + max_count_++; + cout << "svc: waiting (" << ACE_OS::thr_self () << ")" << endl; + } + + while (1) + { + { + ACE_GUARD_RETURN (ACE_Token, ace_mon, token, 0); + + if (max_count_ >= num_threads_) + break; + else + { + ace_mon.release (); + ACE_Thread::yield (); + ace_mon.acquire (); + } + } + + { + ACE_GUARD_RETURN (ACE_Token, ace_mon, token, 0); + + cout << "svc: waiting (" << ACE_OS::thr_self () << ") finished" << endl; + } + } + + delete (Test_Task *) arg; + + return 0; +} + +int +main (int argc, char **argv) +{ + if (argc != 2) + { + cout << "Missing parameters!" << endl; + return 1; + } + + int num_Tasks = atoi (argv[1]); + + num_threads_ = num_Tasks; + + Test_Task **task_arr = (Test_Task**) new char[sizeof (Test_Task*) * num_Tasks]; + + while (1) + { + { + ACE_GUARD_RETURN (ACE_Token, ace_mon, token, -1); + + cout << "ReseTest_Tasking Test_Task::max_count_ from: " + << Test_Task::max_count_ << endl; + + Test_Task::max_count_ = 0; + } + + for (int i = 0; i < num_Tasks; i++) + { + task_arr[i] = new Test_Task; + task_arr[i]->open (task_arr[i]); + } + + cout << "Waiting for first thread started..." << endl; + + for (;;) + { + ACE_GUARD_RETURN (ACE_Token, ace_mon, token, -1); + + if (Test_Task::max_count_ != 0 ) + { + ace_mon.release (); + ACE_Thread::yield (); + ace_mon.acquire (); + break; + } + ace_mon.release (); + ACE_Thread::yield (); + ace_mon.acquire (); + } + + { + ACE_GUARD_RETURN (ACE_Token, ace_mon, token, -1); + + cout << "First thread started!" << endl + << "Waiting for all threads finished..." << endl; + } + + for (;;) + { + ACE_GUARD_RETURN (ACE_Token, ace_mon, token, -1); + + if (!(Test_Task::max_count_ == num_threads_ + && Test_Task::wait_count_ == 0)) + { + ace_mon.release (); + ACE_Thread::yield (); + ace_mon.acquire (); + continue; + } + + cout << "Test_Task::max_count_ = " + << Test_Task::max_count_ + << " Test_Task::wait_count_ = " + << Test_Task::wait_count_ + << endl; + break; + } + + { + ACE_GUARD_RETURN (ACE_Token, ace_mon, token, -1); + cout << "All threads finished..." << endl; + } + + ACE_OS::sleep (2); + } + + return 0; +} + +#else +int +main (int, char *[]) +{ + ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); + return 0; +} +#endif /* ACE_HAS_THREADS */ |