1 // This server daemon collects, formats, and displays logging
2 // information forwarded from client daemons running on other hosts in
5 // In addition, it also illustrates how the ACE_Reactor framework is
8 #include "ace/Get_Opt.h"
9 #include "ace/Log_Msg.h"
10 #include "ace/Signal.h"
12 #include "Logging_Acceptor.h"
13 #include "Reactor_Singleton.h"
15 static sig_atomic_t finished
= 0;
23 // It doesn't get anymore const than this....
24 static const u_short PORT
= ACE_DEFAULT_SERVER_PORT
;
27 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
29 // Register a signal handler.
30 ACE_Sig_Action
sa ((ACE_SignalHandler
) handler
, SIGINT
);
33 Logging_Acceptor
*peer_acceptor
;
34 ACE_NEW_RETURN (peer_acceptor
,
38 ACE_INET_Addr
addr (PORT
);
40 ACE_Get_Opt
get_opt (argc
, argv
, ACE_TEXT ("p:"));
42 for (int c
; (c
= get_opt ()) != -1; )
46 addr
.set (ACE_OS::atoi (get_opt
.opt_arg ()));
52 if (peer_acceptor
->open (addr
) == -1)
53 ACE_ERROR_RETURN ((LM_ERROR
,
57 else if (REACTOR::instance ()->register_handler (peer_acceptor
,
58 ACE_Event_Handler::ACCEPT_MASK
) == -1)
59 ACE_ERROR_RETURN ((LM_ERROR
,
60 ACE_TEXT ("registering service with ACE_Reactor\n")),
63 // Run forever, performing the logging service.
66 ACE_TEXT ("(%P|%t) starting up server logging daemon\n")));
69 REACTOR::instance ()->handle_events ();
72 ACE_TEXT ("(%P|%t) shutting down server logging daemon\n")));
76 ACE_SINGLETON_TEMPLATE_INSTANTIATE(ACE_Singleton
, ACE_Reactor
, ACE_Null_Mutex
);