summaryrefslogtreecommitdiff
path: root/ACE/examples/C++NPv2/Logging_Acceptor.h
blob: e49b5d7a7d3a21ec73077a6425ddb84702052d62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
** Copyright 2002 Addison Wesley. All Rights Reserved.
*/

#ifndef _LOGGING_ACCEPTOR_H
#define _LOGGING_ACCEPTOR_H

#include "ace/Event_Handler.h"
#include "ace/INET_Addr.h"
#include "ace/Log_Record.h"
#include "ace/Reactor.h"
#include "ace/SOCK_Acceptor.h"
#include "ace/SOCK_Stream.h"
#include "Logging_Handler.h"

class Logging_Acceptor : public ACE_Event_Handler
{
protected:
  // Factory that connects <ACE_SOCK_Stream>s passively.
  ACE_SOCK_Acceptor acceptor_;

protected:
  virtual ~Logging_Acceptor () {}; // No-op destructor.

public:
  typedef ACE_INET_Addr PEER_ADDR;

  // Simple constructor.
  Logging_Acceptor (ACE_Reactor *r = ACE_Reactor::instance ())
    : ACE_Event_Handler (r) {};

  // Initialization method.
  virtual int open (const ACE_INET_Addr &local_addr);

  // Called by a reactor when there's a new connection to accept.
  virtual int handle_input (ACE_HANDLE = ACE_INVALID_HANDLE);

  // Called when this object is destroyed, e.g., when it's
  // removed from a reactor.
  virtual int handle_close (ACE_HANDLE = ACE_INVALID_HANDLE,
                            ACE_Reactor_Mask = 0);

  // Return the passive-mode socket's I/O handle.
  virtual ACE_HANDLE get_handle () const
    { return acceptor_.get_handle (); };

  // Returns a reference to the underlying <acceptor_>.
  ACE_SOCK_Acceptor &acceptor () { return acceptor_; };
};

#endif /* _LOGGING_ACCEPTOR_H */