diff options
Diffstat (limited to 'examples/Logger')
-rw-r--r-- | examples/Logger/Acceptor-server/Makefile | 107 | ||||
-rw-r--r-- | examples/Logger/Acceptor-server/server_loggerd.cpp | 268 | ||||
-rw-r--r-- | examples/Logger/Makefile | 27 | ||||
-rw-r--r-- | examples/Logger/README | 32 | ||||
-rw-r--r-- | examples/Logger/client/Makefile | 43 | ||||
-rw-r--r-- | examples/Logger/client/logging_app.cpp | 53 | ||||
-rw-r--r-- | examples/Logger/simple-server/Logging_Acceptor.cpp | 64 | ||||
-rw-r--r-- | examples/Logger/simple-server/Logging_Acceptor.h | 49 | ||||
-rw-r--r-- | examples/Logger/simple-server/Logging_Handler.cpp | 139 | ||||
-rw-r--r-- | examples/Logger/simple-server/Logging_Handler.h | 64 | ||||
-rw-r--r-- | examples/Logger/simple-server/Makefile | 116 | ||||
-rw-r--r-- | examples/Logger/simple-server/Reactor_Singleton.h | 27 | ||||
-rw-r--r-- | examples/Logger/simple-server/server_loggerd.cpp | 61 |
13 files changed, 0 insertions, 1050 deletions
diff --git a/examples/Logger/Acceptor-server/Makefile b/examples/Logger/Acceptor-server/Makefile deleted file mode 100644 index caf3e445e80..00000000000 --- a/examples/Logger/Acceptor-server/Makefile +++ /dev/null @@ -1,107 +0,0 @@ -#---------------------------------------------------------------------------- -# @(#)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 deleted file mode 100644 index 2ae054cb445..00000000000 --- a/examples/Logger/Acceptor-server/server_loggerd.cpp +++ /dev/null @@ -1,268 +0,0 @@ -// This server daemon collects, formats, and displays logging -// $Id$ - -// 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 deleted file mode 100644 index 05c41ee6fc2..00000000000 --- a/examples/Logger/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -#---------------------------------------------------------------------------- -# @(#)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 deleted file mode 100644 index 9fa30aafbc0..00000000000 --- a/examples/Logger/README +++ /dev/null @@ -1,32 +0,0 @@ -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 deleted file mode 100644 index 665086e9d8f..00000000000 --- a/examples/Logger/client/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -#---------------------------------------------------------------------------- -# @(#)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 deleted file mode 100644 index f14b8d0ec7b..00000000000 --- a/examples/Logger/client/logging_app.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// This program sends logging records directly to the server, rather -// $Id$ - -// 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 deleted file mode 100644 index b23d6f7f403..00000000000 --- a/examples/Logger/simple-server/Logging_Acceptor.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#include "ace/Log_Msg.h" -// $Id$ - -#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 deleted file mode 100644 index b653774ddd0..00000000000 --- a/examples/Logger/simple-server/Logging_Acceptor.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - - -// ============================================================================ -// -// = 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 deleted file mode 100644 index 596f7974885..00000000000 --- a/examples/Logger/simple-server/Logging_Handler.cpp +++ /dev/null @@ -1,139 +0,0 @@ -#include "ace/Log_Msg.h" -// $Id$ - -#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 deleted file mode 100644 index 2d15b5a6295..00000000000 --- a/examples/Logger/simple-server/Logging_Handler.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - - -// ============================================================================ -// -// = 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 deleted file mode 100644 index 773d9f513b8..00000000000 --- a/examples/Logger/simple-server/Makefile +++ /dev/null @@ -1,116 +0,0 @@ -#---------------------------------------------------------------------------- -# @(#)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 deleted file mode 100644 index 44f2a91eda7..00000000000 --- a/examples/Logger/simple-server/Reactor_Singleton.h +++ /dev/null @@ -1,27 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - - -// ============================================================================ -// -// = 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 deleted file mode 100644 index 7397fc501e2..00000000000 --- a/examples/Logger/simple-server/server_loggerd.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// This server daemon collects, formats, and displays logging -// $Id$ - -// 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; -} |