2 ** Copyright 2001 Addison Wesley. All Rights Reserved.
5 #ifndef _ITERATIVE_LOGGING_SERVER_H
6 #define _ITERATIVE_LOGGING_SERVER_H
8 #include "ace/FILE_IO.h"
9 #include "ace/INET_Addr.h"
10 #include "ace/Log_Msg.h"
12 #include "Logging_Handler.h"
13 #include "Logging_Server.h"
15 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
16 class ACE_SOCK_Stream
;
17 ACE_END_VERSIONED_NAMESPACE_DECL
19 class Iterative_Logging_Server
: public Logging_Server
22 ACE_FILE_IO log_file_
;
23 Logging_Handler logging_handler_
;
26 Iterative_Logging_Server () : logging_handler_ (log_file_
) {}
28 virtual ~Iterative_Logging_Server () { log_file_
.close (); }
30 Logging_Handler
&logging_handler () { return logging_handler_
; }
33 // Override inherited open() from Logging_Server
34 virtual int open (u_short port
) {
35 if (make_log_file (log_file_
) == -1)
36 ACE_ERROR_RETURN ((LM_ERROR
, "%p\n", "make_log_file()"), -1);
37 return Logging_Server::open (port
);
40 virtual int handle_connections () {
41 ACE_INET_Addr logging_peer_addr
;
43 if (acceptor ().accept (logging_handler_
.peer (),
44 &logging_peer_addr
) == -1)
45 ACE_ERROR_RETURN ((LM_ERROR
, "%p\n", "acceptor.accept()"), -1);
47 ACE_DEBUG ((LM_DEBUG
, "Accepted connection from %s\n",
48 logging_peer_addr
.get_host_name ()));
52 virtual int handle_data (ACE_SOCK_Stream
*) {
53 while (logging_handler_
.log_record () != -1)
56 logging_handler_
.close (); // Close the socket handle.
61 #endif /* _ITERATIVE_LOGGING_SERVER_H */