diff options
Diffstat (limited to 'examples/Logger')
20 files changed, 0 insertions, 1049 deletions
diff --git a/examples/Logger/Acceptor-server/.cvsignore b/examples/Logger/Acceptor-server/.cvsignore deleted file mode 100644 index 76c31d8c56f..00000000000 --- a/examples/Logger/Acceptor-server/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -server_loggerd -server_loggerd diff --git a/examples/Logger/Acceptor-server/Logger_Acceptor_Server.mpc b/examples/Logger/Acceptor-server/Logger_Acceptor_Server.mpc deleted file mode 100644 index 1e4d8240e38..00000000000 --- a/examples/Logger/Acceptor-server/Logger_Acceptor_Server.mpc +++ /dev/null @@ -1,6 +0,0 @@ -// -*- MPC -*- -// $Id$ - -project : aceexe { - exename = server_loggerd -}
\ No newline at end of file diff --git a/examples/Logger/Acceptor-server/Makefile.am b/examples/Logger/Acceptor-server/Makefile.am deleted file mode 100644 index 0e5bc9a2bd4..00000000000 --- a/examples/Logger/Acceptor-server/Makefile.am +++ /dev/null @@ -1,36 +0,0 @@ -## Process this file with automake to create Makefile.in -## -## $Id$ -## -## This file was generated by MPC. Any changes made directly to -## this file will be lost the next time it is generated. -## -## MPC Command: -## /acebuilds/ACE_wrappers-repository/bin/mwc.pl -include /acebuilds/MPC/config -include /acebuilds/MPC/templates -feature_file /acebuilds/ACE_wrappers-repository/local.features -noreldefs -type automake -exclude build,Kokyu - -ACE_BUILDDIR = $(top_builddir) -ACE_ROOT = $(top_srcdir) - -## Makefile.Logger_Acceptor_Server.am -noinst_LTLIBRARIES = libLogger_Acceptor_Server.la - -libLogger_Acceptor_Server_la_CPPFLAGS = \ - -I$(ACE_ROOT) \ - -I$(ACE_BUILDDIR) - -libLogger_Acceptor_Server_la_SOURCES = \ - server_loggerd.cpp - -libLogger_Acceptor_Server_la_LIBADD = \ - $(top_builddir)/ace/libACE.la - -noinst_HEADERS = \ - server_loggerd.h - -## Clean up template repositories, etc. -clean-local: - -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.* - -rm -f gcctemp.c gcctemp so_locations *.ics - -rm -rf cxx_repository ptrepository ti_files - -rm -rf templateregistry ir.out - -rm -rf ptrepository SunWS_cache Templates.DB diff --git a/examples/Logger/Acceptor-server/server_loggerd.cpp b/examples/Logger/Acceptor-server/server_loggerd.cpp deleted file mode 100644 index 159bcdf93ce..00000000000 --- a/examples/Logger/Acceptor-server/server_loggerd.cpp +++ /dev/null @@ -1,255 +0,0 @@ -// $Id$ -// server_loggerd.cpp,v 4.29 2003/12/30 23:18:59 shuston Exp - -// This server daemon collects, formats, and displays logging -// 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 the ACE_Test_and_Set -// components. - -#include "ace/OS_NS_string.h" -#include "ace/Get_Opt.h" -#include "ace/Acceptor.h" -#include "ace/Null_Mutex.h" -#include "ace/SOCK_Acceptor.h" -#include "ace/Singleton.h" -#include "ace/Test_and_Set.h" - -// FUZZ: disable check_for_streams_include -#include "ace/streams.h" - -#include "ace/Log_Record.h" -#include "ace/Test_and_Set.h" - -#include "server_loggerd.h" - -ACE_RCSID(Acceptor_server, server_loggerd, "$Id$") - -// ---------------------------------------- - -// Return the port number. - -u_short -Options::port (void) -{ - return this->port_; -} - -// Parse the command-line options. - -void -Options::parse_args (int argc, ACE_TCHAR *argv[]) -{ - this->port_ = ACE_DEFAULT_SERVER_PORT; - - ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("p:")); - - for (int c; (c = get_opt ()) != -1; ) - switch (c) - { - case 'p': - this->port_ = ACE_OS::atoi (get_opt.opt_arg ()); - 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; - -// ---------------------------------------- - -// Specialize a Logging Acceptor. -typedef ACE_Acceptor <Logging_Handler, ACE_SOCK_ACCEPTOR> -Logging_Acceptor; - -// Default constructor. - -Logging_Handler::Logging_Handler (void) -{ -} - -int -Logging_Handler::handle_timeout (const ACE_Time_Value &, - const void *arg) -{ -#if defined (ACE_NDEBUG) - ACE_UNUSED_ARG (arg); -#endif /* ACE_NDEBUG */ - - ACE_ASSERT (arg == this); - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) handling timeout from this = %@\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, ACE_TEXT ("(%P|%t) %p at host %C\n"), - ACE_TEXT ("client logger"), this->peer_name_), -1); - /* NOTREACHED */ - case 0: - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("(%P|%t) closing log daemon at host %C (fd = %d)\n"), - this->peer_name_, this->get_handle ()), -1); - /* NOTREACHED */ - case sizeof (size_t): - { - ACE_Log_Record lp; - - len = ntohl (len); - n = this->peer ().recv_n ((void *) &lp, len); - - if (n != len) - ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%P|%t) %p at host %C\n"), - ACE_TEXT ("client logger"), this->peer_name_),-1); - /* NOTREACHED */ - - lp.decode (); - - if (lp.length () == n) - { - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) "))); -#if !defined (ACE_LACKS_IOSTREAM_TOTALLY) - lp.print (ACE_TEXT_CHAR_TO_TCHAR (this->peer_name_), 1, cerr); -#else - lp.print (ACE_TEXT_CHAR_TO_TCHAR (this->peer_name_), 1, stderr); -#endif - } - else - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("(%P|%t) error, lp.length = %d, n = %d\n"), - lp.length (), n)); - break; - } - default: - ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%P|%t) %p at host %C\n"), - ACE_TEXT ("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, READ_MASK) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("(%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, - ACE_TEXT ("(%P|%t) can't register with reactor\n")), - -1); - else - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) connected with %C\n"), - this->peer_name_)); - return 0; - } -} - -int -ACE_TMAIN (int argc, ACE_TCHAR *argv[]) -{ - // Acceptor factory. - Logging_Acceptor peer_acceptor; - - OPTIONS::instance ()->parse_args (argc, argv); - - // We need to pass in REACTOR::instance () here so that we don't use - // the default ACE_Reactor::instance (). - - if (peer_acceptor.open - (ACE_INET_Addr (OPTIONS::instance ()->port ()), - REACTOR::instance ()) == -1) - ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")), -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, - ACE_TEXT ("registering service with ACE_Reactor\n")), - -1); - - // Run forever, performing logging service. - - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%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, - ACE_TEXT ("(%P|%t) shutting down server logging daemon\n"))); - - return 0; -} - -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) -template class ACE_Acceptor<Logging_Handler, ACE_SOCK_ACCEPTOR>; -template class ACE_Singleton<ACE_Reactor, ACE_Null_Mutex>; -template class ACE_Singleton<ACE_Test_and_Set <ACE_Null_Mutex, sig_atomic_t>, ACE_Null_Mutex>; -template class ACE_Singleton<Options, ACE_Null_Mutex>; -template class ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>; -template class ACE_Test_and_Set<ACE_Null_Mutex, sig_atomic_t>; -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) -#pragma instantiate ACE_Acceptor<Logging_Handler, ACE_SOCK_ACCEPTOR> -#pragma instantiate ACE_Singleton<ACE_Reactor, ACE_Null_Mutex> -#pragma instantiate ACE_Singleton<ACE_Test_and_Set <ACE_Null_Mutex, sig_atomic_t>, ACE_Null_Mutex> -#pragma instantiate ACE_Singleton<Options, ACE_Null_Mutex> -#pragma instantiate ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> -#pragma instantiate ACE_Test_and_Set<ACE_Null_Mutex, sig_atomic_t> -#elif defined (ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION) -template ACE_Singleton<ACE_Reactor, ACE_Null_Mutex> * - ACE_Singleton<ACE_Reactor, ACE_Null_Mutex>::singleton_; -template ACE_Singleton<Options, ACE_Null_Mutex> * - ACE_Singleton<Options, ACE_Null_Mutex>::singleton_; -template ACE_Singleton<ACE_Test_and_Set <ACE_Null_Mutex, sig_atomic_t>, ACE_Null_Mutex> * - ACE_Singleton<ACE_Test_and_Set <ACE_Null_Mutex, sig_atomic_t>, ACE_Null_Mutex>::singleton_; -#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/examples/Logger/Acceptor-server/server_loggerd.h b/examples/Logger/Acceptor-server/server_loggerd.h deleted file mode 100644 index 33d5f0042ee..00000000000 --- a/examples/Logger/Acceptor-server/server_loggerd.h +++ /dev/null @@ -1,54 +0,0 @@ -// $Id$ - -// Define classes used with templates in server_loggerd.h. - -#ifndef __SERVER_LOGGERD_H -#define __SERVER_LOGGERD_H - -#include "ace/SOCK_Stream.h" -#include "ace/Svc_Handler.h" -#include "ace/os_include/os_netdb.h" - -class Options -{ - // = TITLE - // Keeps track of the options. -public: - void parse_args (int argc, ACE_TCHAR *argv[]); - u_short port (void); - -private: - u_short port_; - // Port number; -}; - - -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); - - // = Hooks for opening and closing handlers. - virtual int open (void *); - -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. -}; - -#endif /* __SERVER_LOGGERD_H */ diff --git a/examples/Logger/Makefile.am b/examples/Logger/Makefile.am deleted file mode 100644 index 3aa67282ba4..00000000000 --- a/examples/Logger/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -## Process this file with automake to create Makefile.in -## -## $Id$ -## -## This file was generated by MPC. Any changes made directly to -## this file will be lost the next time it is generated. -## -## MPC Command: -## /acebuilds/ACE_wrappers-repository/bin/mwc.pl -include /acebuilds/MPC/config -include /acebuilds/MPC/templates -feature_file /acebuilds/ACE_wrappers-repository/local.features -noreldefs -type automake -exclude build,Kokyu - -SUBDIRS = \ - Acceptor-server \ - client \ - simple-server - diff --git a/examples/Logger/README b/examples/Logger/README deleted file mode 100644 index bac9aa1d127..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 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: - -$ACE_ROOT/netsvcs/{clients,lib,servers} - -directories. - diff --git a/examples/Logger/client/.cvsignore b/examples/Logger/client/.cvsignore deleted file mode 100644 index 6c538132cc9..00000000000 --- a/examples/Logger/client/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -logging_app -logging_app diff --git a/examples/Logger/client/Logger_client.mpc b/examples/Logger/client/Logger_client.mpc deleted file mode 100644 index ec75f197b14..00000000000 --- a/examples/Logger/client/Logger_client.mpc +++ /dev/null @@ -1,6 +0,0 @@ -// -*- MPC -*- -// $Id$ - -project : aceexe { - exename = logging_app -}
\ No newline at end of file diff --git a/examples/Logger/client/Makefile.am b/examples/Logger/client/Makefile.am deleted file mode 100644 index 7d71178989f..00000000000 --- a/examples/Logger/client/Makefile.am +++ /dev/null @@ -1,33 +0,0 @@ -## Process this file with automake to create Makefile.in -## -## $Id$ -## -## This file was generated by MPC. Any changes made directly to -## this file will be lost the next time it is generated. -## -## MPC Command: -## /acebuilds/ACE_wrappers-repository/bin/mwc.pl -include /acebuilds/MPC/config -include /acebuilds/MPC/templates -feature_file /acebuilds/ACE_wrappers-repository/local.features -noreldefs -type automake -exclude build,Kokyu - -ACE_BUILDDIR = $(top_builddir) -ACE_ROOT = $(top_srcdir) - -## Makefile.Logger_client.am -noinst_LTLIBRARIES = libLogger_client.la - -libLogger_client_la_CPPFLAGS = \ - -I$(ACE_ROOT) \ - -I$(ACE_BUILDDIR) - -libLogger_client_la_SOURCES = \ - logging_app.cpp - -libLogger_client_la_LIBADD = \ - $(top_builddir)/ace/libACE.la - -## Clean up template repositories, etc. -clean-local: - -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.* - -rm -f gcctemp.c gcctemp so_locations *.ics - -rm -rf cxx_repository ptrepository ti_files - -rm -rf templateregistry ir.out - -rm -rf ptrepository SunWS_cache Templates.DB diff --git a/examples/Logger/client/logging_app.cpp b/examples/Logger/client/logging_app.cpp deleted file mode 100644 index ba5bb24295e..00000000000 --- a/examples/Logger/client/logging_app.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// $Id$ - -// This program sends logging records directly to the server, rather -// than going through the client logging daemon. - -#include "ace/SOCK_Connector.h" -#include "ace/Log_Record.h" -#include "ace/Log_Msg.h" -#include "ace/OS_NS_time.h" -#include "ace/OS_NS_stdio.h" -#include "ace/OS_NS_stdlib.h" -#include "ace/OS_NS_unistd.h" - -ACE_RCSID(client, logging_app, "$Id$") - -static u_short LOGGER_PORT = ACE_DEFAULT_SERVER_PORT; -static const ACE_TCHAR *const LOGGER_HOST = ACE_DEFAULT_SERVER_HOST; -static const int MAX_ITERATIONS = 10; - -int -ACE_TMAIN (int argc, ACE_TCHAR *argv[]) -{ - const ACE_TCHAR *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, ACE_TEXT ("%p\n"), ACE_TEXT ("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 ()); - - ACE_TCHAR buf[BUFSIZ]; - ACE_OS::sprintf (buf, ACE_TEXT ("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, ACE_TEXT ("%p\n"), ACE_TEXT ("send")),-1); - else - ACE_OS::sleep (1); - } - - if (logger.close () == -1) - ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("close")), -1); - - return 0; -} diff --git a/examples/Logger/simple-server/.cvsignore b/examples/Logger/simple-server/.cvsignore deleted file mode 100644 index 76c31d8c56f..00000000000 --- a/examples/Logger/simple-server/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -server_loggerd -server_loggerd diff --git a/examples/Logger/simple-server/Logger_Simple_Server.mpc b/examples/Logger/simple-server/Logger_Simple_Server.mpc deleted file mode 100644 index 1e4d8240e38..00000000000 --- a/examples/Logger/simple-server/Logger_Simple_Server.mpc +++ /dev/null @@ -1,6 +0,0 @@ -// -*- MPC -*- -// $Id$ - -project : aceexe { - exename = server_loggerd -}
\ No newline at end of file diff --git a/examples/Logger/simple-server/Logging_Acceptor.cpp b/examples/Logger/simple-server/Logging_Acceptor.cpp deleted file mode 100644 index 7e5e0d0075c..00000000000 --- a/examples/Logger/simple-server/Logging_Acceptor.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// $Id$ - -#include "ace/WFMO_Reactor.h" -#include "ace/Log_Msg.h" - -#include "Logging_Acceptor.h" -#include "Logging_Handler.h" -#include "Reactor_Singleton.h" - -ACE_RCSID(simple_server, Logging_Acceptor, "$Id$") - -// 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) -{ - this->peer_acceptor_.close (); - // Note, this object MUST be allocated dynamically! - delete this; - return 0; -} - -Logging_Acceptor::~Logging_Acceptor (void) -{ -} - -// 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; - - ACE_NEW_RETURN (svc_handler, Logging_Handler, -1); - - // Accept the connection from a client client daemon. - - // Try to find out if the implementation of the reactor that we are - // using requires us to reset the event association for the newly - // created handle. This is because the newly created handle will - // inherit the properties of the listen handle, including its event - // associations. - int reset_new_handle = this->reactor ()->uses_event_associations (); - - if (this->peer_acceptor_.accept (svc_handler->peer (), // stream - 0, // remote address - 0, // timeout - 1, // restart - reset_new_handle // reset new handler - ) == -1 - || svc_handler->open () == -1) - { - svc_handler->close (); - ACE_ERROR_RETURN ((LM_ERROR, "%p", "accept/open failed"), -1); - } - - 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 0424a7c3889..00000000000 --- a/examples/Logger/simple-server/Logging_Acceptor.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// examples -// -// = FILENAME -// Logging_Acceptor.h -// -// = AUTHOR -// Doug Schmidt -// -// ============================================================================ - -#ifndef _CLIENT_ACCEPTOR_H -#define _CLIENT_ACCEPTOR_H - -#include "ace/SOCK_Acceptor.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#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); - // Constructor. - - int open (const ACE_INET_Addr &a); - // Initialization. - -private: - // = Demuxing hooks. - virtual int handle_input (ACE_HANDLE); - virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask); - virtual ACE_HANDLE get_handle (void) const; - - ~Logging_Acceptor (void); - // By making this private we ensure that the <Logging_Acceptor> is - // allocated dynamically. - - 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 111a26248fc..00000000000 --- a/examples/Logger/simple-server/Logging_Handler.cpp +++ /dev/null @@ -1,164 +0,0 @@ -// $Id$ - -#include "ace/Log_Msg.h" - -#include "Logging_Handler.h" -#include "Reactor_Singleton.h" -#include "ace/Log_Record.h" -#include "ace/OS_NS_string.h" - -ACE_RCSID(simple_server, Logging_Handler, "$Id$") - -// Default constructor. - -Logging_Handler::Logging_Handler (void) -{ -} - -Logging_Handler::~Logging_Handler (void) -{ - // Make sure there are no timers. - REACTOR::instance ()->cancel_timer (this); - - this->cli_stream_.close (); -} - -// Extract the underlying ACE_SOCK_Stream (e.g., for purposes of -// accept()). - -ACE_SOCK_Stream & -Logging_Handler::peer (void) -{ - return this->cli_stream_; -} - -int -Logging_Handler::handle_timeout (const ACE_Time_Value &, - const void *arg) -{ -#if defined (ACE_NDEBUG) - ACE_UNUSED_ARG (arg); -#endif /* ACE_NDEBUG */ - - ACE_ASSERT (arg == this); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) handling timeout from this = %@\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, ACE_TEXT ("(%P|%t) %p at host %C\n"), - ACE_TEXT ("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); - n = this->cli_stream_.recv_n ((void *) &lp, len); - if (n != (ssize_t) len) - ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%P|%t) %p at host %C\n"), - ACE_TEXT ("client logger"), this->host_name_), -1); - /* NOTREACHED */ - - lp.decode (); - - if (lp.length () == n) - { - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) "))); - lp.print (ACE_TEXT_CHAR_TO_TCHAR (this->host_name_), 1); - } - else - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("(%P|%t) error, lp.length = %d, n = %d\n"), - lp.length (), n)); - break; - } - default: - ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%P|%t) %p at host %C\n"), - ACE_TEXT ("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, READ_MASK) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("(%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, - ACE_TEXT ("(%P|%t) can't register with reactor\n")), - -1); - else - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) connected with %C\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 have been allocated dynamically - delete this; - return 0; -} - -// Perform termination activities when close fails. - -int -Logging_Handler::close (void) -{ - return this->handle_close (); -} diff --git a/examples/Logger/simple-server/Logging_Handler.h b/examples/Logger/simple-server/Logging_Handler.h deleted file mode 100644 index 633e04a167c..00000000000 --- a/examples/Logger/simple-server/Logging_Handler.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - - -// ============================================================================ -// -// = LIBRARY -// examples -// -// = FILENAME -// Logging_Handler.h -// -// = AUTHOR -// Doug Schmidt -// -// ============================================================================ - -#ifndef _CLIENT_HANDLER_H -#define _CLIENT_HANDLER_H - -#include "ace/Event_Handler.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/INET_Addr.h" -#include "ace/SOCK_Stream.h" -#include "ace/os_include/os_netdb.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); - - ACE_SOCK_Stream &peer (void); - // 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_INVALID_HANDLE, - ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_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.am b/examples/Logger/simple-server/Makefile.am deleted file mode 100644 index fa71e2916eb..00000000000 --- a/examples/Logger/simple-server/Makefile.am +++ /dev/null @@ -1,40 +0,0 @@ -## Process this file with automake to create Makefile.in -## -## $Id$ -## -## This file was generated by MPC. Any changes made directly to -## this file will be lost the next time it is generated. -## -## MPC Command: -## /acebuilds/ACE_wrappers-repository/bin/mwc.pl -include /acebuilds/MPC/config -include /acebuilds/MPC/templates -feature_file /acebuilds/ACE_wrappers-repository/local.features -noreldefs -type automake -exclude build,Kokyu - -ACE_BUILDDIR = $(top_builddir) -ACE_ROOT = $(top_srcdir) - -## Makefile.Logger_Simple_Server.am -noinst_LTLIBRARIES = libLogger_Simple_Server.la - -libLogger_Simple_Server_la_CPPFLAGS = \ - -I$(ACE_ROOT) \ - -I$(ACE_BUILDDIR) - -libLogger_Simple_Server_la_SOURCES = \ - Logging_Acceptor.cpp \ - Logging_Handler.cpp \ - server_loggerd.cpp - -libLogger_Simple_Server_la_LIBADD = \ - $(top_builddir)/ace/libACE.la - -noinst_HEADERS = \ - Logging_Acceptor.h \ - Logging_Handler.h \ - Reactor_Singleton.h - -## Clean up template repositories, etc. -clean-local: - -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.* - -rm -f gcctemp.c gcctemp so_locations *.ics - -rm -rf cxx_repository ptrepository ti_files - -rm -rf templateregistry ir.out - -rm -rf ptrepository SunWS_cache Templates.DB diff --git a/examples/Logger/simple-server/Reactor_Singleton.h b/examples/Logger/simple-server/Reactor_Singleton.h deleted file mode 100644 index ec0653125a9..00000000000 --- a/examples/Logger/simple-server/Reactor_Singleton.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - - -// ============================================================================ -// -// = LIBRARY -// examples -// -// = FILENAME -// Reactor_Singleton.h -// -// = AUTHOR -// Doug Schmidt -// -// ============================================================================ - -#ifndef _REACTOR_SINGLETON_H -#define _REACTOR_SINGLETON_H - -#include "ace/Singleton.h" -#include "ace/Null_Mutex.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#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 49981dc92ff..00000000000 --- a/examples/Logger/simple-server/server_loggerd.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// $Id$ - -// This server daemon collects, formats, and displays logging -// 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 "ace/Signal.h" - -#include "Logging_Acceptor.h" -#include "Reactor_Singleton.h" - -ACE_RCSID(simple_server, server_loggerd, "$Id$") - -static sig_atomic_t finished = 0; - -extern "C" void -handler (int) -{ - finished = 1; -} - -// It doesn't get anymore const than this.... -static const u_short PORT = ACE_DEFAULT_SERVER_PORT; - -int -ACE_TMAIN (int argc, ACE_TCHAR *argv[]) -{ - // Register a signal handler. - ACE_Sig_Action sa ((ACE_SignalHandler) handler, SIGINT); - ACE_UNUSED_ARG (sa); - - Logging_Acceptor *peer_acceptor; - ACE_NEW_RETURN (peer_acceptor, - Logging_Acceptor, - 1); - - ACE_INET_Addr addr (PORT); - - ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("p:")); - - for (int c; (c = get_opt ()) != -1; ) - switch (c) - { - case 'p': - addr.set (ACE_OS::atoi (get_opt.opt_arg ())); - break; - default: - break; - } - - if (peer_acceptor->open (addr) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("open")), - -1); - else if (REACTOR::instance ()->register_handler - (peer_acceptor, - ACE_Event_Handler::ACCEPT_MASK) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("registering service with ACE_Reactor\n")), - -1); - - // Run forever, performing the logging service. - - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) starting up server logging daemon\n"))); - - while (!finished) - REACTOR::instance ()->handle_events (); - - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) shutting down server logging daemon\n"))); - return 0; -} - - -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) -template class ACE_Singleton<ACE_Reactor, ACE_Null_Mutex>; -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) -#pragma instantiate ACE_Singleton<ACE_Reactor, ACE_Null_Mutex> -#elif defined (ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION) -template ACE_Singleton<ACE_Reactor, ACE_Null_Mutex> * - ACE_Singleton<ACE_Reactor, ACE_Null_Mutex>::singleton_; -#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ |