summaryrefslogtreecommitdiff
path: root/ace/CLASSIX/CLASSIX_CO_Acceptor.h
blob: 02f58f89bb41c7fb1020f6ccba12c73a1b56a5fb (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/* -*- C++ -*- */
// $Id$

// ============================================================================
//
// = LIBRARY
//    ACE
//
// = FILENAME
//    CLASSIX_CO_Acceptor.h
//
// = AUTHOR
//    Nokia Telecommunications
//
// ============================================================================

#ifndef ACE_CLASSIX_CO_ACCEPTOR_H
#define ACE_CLASSIX_CO_ACCEPTOR_H

#include "ace/CLASSIX/CLASSIX_Stream.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "ace/Time_Value.h"

class ACE_Export ACE_CLASSIX_CO_Acceptor
{
  // = TITLE
  //     Defines the format and interface for a connection
  //     oriented <ACE_CLASSIX_Stream>  acceptor.
  //
  // = DESCRIPTION
  //     This class is the counter part of the <ACE_CLASSIX_Connector>
  //     class.  It exchanges SAP information to set up a logical
  //     connection.
  //
  //     Data format passed between a connector and this class uses
  //     Peer_Union structure.
  //
  // = SEE ALSO
  //     ACE_CLASSIX_Connector
  //
public:
  struct Peer_Port
  {
    KnUniqueId peer;
  };

  struct Peer_Group
  {
    KnCap  peer;
  };

  struct Peer_Stamp
  {
    int    peer;
  };

  struct Peer_Union
  {
    int type;
    union
    {
      Peer_Port port;
      Peer_Group group;
      Peer_Stamp stamp;
    }choose;
  };

  // = Initialization methods.
  ACE_CLASSIX_CO_Acceptor (ACE_Reactor* = ACE_Reactor::instance());
  // Default constructor.

  ACE_CLASSIX_CO_Acceptor (const ACE_Addr &local_sap,
                           int reuse_addr = 0,
                           int protocol_family = ACE_CLASSIX_Addr::AF_CLASSIX,
                           int backlog = 0,
                           int protocol = 0,
                           ACE_Reactor* = ACE_Reactor::instance());
  // Initiate a passive mode socket.

  virtual ~ACE_CLASSIX_CO_Acceptor (void);
  // Default dtor.

  int open (const ACE_Addr &local_sap,
            int reuse_addr = 0,
            int protocol_family = ACE_CLASSIX_Addr::AF_CLASSIX,
            int backlog = 5,
            int protocol = 0,
            ACE_Reactor* = ACE_Reactor::instance());
  // Initiate a passive mode socket.
  int close (void);
  // Closes down the listening port.

  // = Passive connection acceptance method.
  int accept (ACE_CLASSIX_Stream &new_stream,
              ACE_Addr *remote_addr = 0,
              ACE_Time_Value *timeout = 0,
              int restart = 1,
              int reset_new_handle = 0) const;
  // Accept a new data transfer connection.  A <timeout> of 0 means
  // block forever, a <timeout> of {0, 0} means poll.  <restart> == 1
  // means "restart if interrupted."

  // = ACCESS
  ACE_HANDLE get_handle (void) const;
  // Get the underlying descriptor.
  int get_local_addr (ACE_Addr &) const;
  // Return the local endpoint address in the referenced ACE_Addr.
  // Returns 0 if successful, else -1.

  void reactor(ACE_Reactor*);
  // reset the reactor

  // = META-TYPE info
  typedef ACE_CLASSIX_Addr PEER_ADDR;
  typedef ACE_CLASSIX_Stream PEER_STREAM;

  void dump (void) const;
  // Dump the state of an object.

  ACE_ALLOC_HOOK_DECLARE;
  // Declare the dynamic allocation hooks.

protected:

private:

  ACE_CLASSIX_Port_Core *port_;
  // optional port.
  // If 0, default port is used.
  ACE_CLASSIX_SAP       addr_;

  ACE_Reactor           *reactor_;
  // for reference only. Does not own it
};

#if !defined (ACE_LACKS_INLINE_FUNCTIONS)
#include "ace/CLASSIX/CLASSIX_CO_Acceptor.i"
#endif /* ACE_LACKS_INLINE_FUNCTIONS */

#endif /* ACE_CLASSIX_CO_ACCEPTOR_H */