Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / MEM_Acceptor.h
blobeebc834e5f67e136a2628b6316145801a684d63f
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file MEM_Acceptor.h
7 * @author Nanbor Wang <nanbor@cs.wustl.edu>
8 */
9 //=============================================================================
11 #ifndef ACE_MEM_ACCEPTOR_H
12 #define ACE_MEM_ACCEPTOR_H
13 #include /**/ "ace/pre.h"
15 #include /**/ "ace/ACE_export.h"
17 #include "ace/SOCK_Acceptor.h"
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
20 # pragma once
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
25 #include "ace/MEM_Stream.h"
26 #include "ace/MEM_Addr.h"
27 #include "ace/OS_QoS.h"
29 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
31 // Forward decl.
32 class ACE_Reactor;
34 /**
35 * @class ACE_MEM_Acceptor
37 * @brief Defines the format and interface for the acceptor side of the
38 * local mmap stream.
40 * This class should be modified to prevent user passing a
41 * non-localhost endpoint as the acceptor listen point because
42 * it doesn't make any sense at all to make the listening
43 * endpoint visible (or connectable) anywhere outside of this
44 * machine. However, the type of endpoint is left as <ACE_Addr>
45 * so we can later changed to use UNIX-domain sockets with mmap stream
46 * if so desired. (Currently, using UNIX-domain sockets, i.e.,
47 * ACE_LSOCK_*, with this class will not work.)
49 class ACE_Export ACE_MEM_Acceptor : public ACE_SOCK_Acceptor
51 public:
52 /// Default constructor.
53 ACE_MEM_Acceptor ();
55 /// Destructor.
56 ~ACE_MEM_Acceptor ();
58 /// Initiate a passive mode socket.
59 ACE_MEM_Acceptor (const ACE_MEM_Addr &remote_sap,
60 int reuse_addr = 0,
61 int backlog = ACE_DEFAULT_BACKLOG,
62 int protocol = 0);
64 /**
65 * Initialize a passive-mode BSD-style acceptor socket (no QoS).
66 * @a local_sap is the address that we're going to listen for
67 * connections on. If @a reuse_addr is 1 then we'll use the
68 * @c SO_REUSEADDR to reuse this address. Returns 0 on success and
69 * -1 on failure.
71 int open (const ACE_MEM_Addr &local_sap,
72 int reuse_addr = 0,
73 int backlog = ACE_DEFAULT_BACKLOG,
74 int protocol = 0);
76 /// Accept a new data transfer connection.
77 int accept (ACE_MEM_Stream &new_ipc_sap,
78 ACE_MEM_Addr *remote_addr = 0,
79 ACE_Time_Value *timeout = 0,
80 bool restart = true,
81 bool reset_new_handle = false);
83 /// Perform operations that must occur after <ACE_OS::accept> is
84 /// called.
85 int shared_accept_finish (ACE_MEM_Stream new_stream,
86 int in_blocking_mode,
87 bool reset_new_handle) const;
89 /**
90 * Accessor/mutator of mmap filename prefix. By default, the
91 * <mmap_prefix_> is not set and the mmap filename is
92 * ${(TMP|TEMP)}//ACE_MEM_Acceptor_(port-number)_(&stream),
93 * otherwise, it is <mmap_prefix_>_(port-number)_(&stream),
94 * <mmap_prefix_> should include _absolute_ path so the connector
95 * within the same host can located the mmap file. Example:
96 * /tmp/mmapfile.
98 const ACE_TCHAR *mmap_prefix () const;
99 void mmap_prefix (const ACE_TCHAR *prefix);
102 * Change the initial MMAP buffer size (in bytes) of the MEM_Stream
103 * this MEM_Acceptor creates.
105 void init_buffer_size (ACE_OFF_T bytes);
107 /// Get the preferred signaling strategy.
108 ACE_MEM_IO::Signal_Strategy preferred_strategy () const;
110 /// Set the preferred signaling strategy.
111 void preferred_strategy (ACE_MEM_IO::Signal_Strategy strategy);
113 /// Return the local endpoint address in the referenced <ACE_Addr>.
114 /// Returns 0 if successful, else -1.
115 int get_local_addr (ACE_MEM_Addr &) const;
117 // = Meta-type info
118 typedef ACE_MEM_Addr PEER_ADDR;
119 typedef ACE_MEM_Stream PEER_STREAM;
121 /// Dump the state of an object.
122 void dump () const;
124 /// Declare the dynamic allocation hooks.
125 ACE_ALLOC_HOOK_DECLARE;
127 protected:
128 // = The following methods should not be accessable externally
129 // because MEM_Acceptor do not support their semantics.
130 int open (const ACE_Addr &local_sap,
131 int reuse_addr = 0,
132 int protocol_family = PF_INET,
133 int backlog = ACE_DEFAULT_BACKLOG,
134 int protocol = 0);
136 int open (const ACE_Addr &local_sap,
137 ACE_Protocol_Info *protocolinfo,
138 ACE_SOCK_GROUP g,
139 u_long flags,
140 int reuse_addr,
141 int protocol_family,
142 int backlog = ACE_DEFAULT_BACKLOG,
143 int protocol = 0);
145 int accept (ACE_SOCK_Stream &new_stream,
146 ACE_Addr *remote_addr = 0,
147 ACE_Time_Value *timeout = 0,
148 bool restart = true,
149 bool reset_new_handle = false) const;
151 int accept (ACE_SOCK_Stream &new_stream,
152 ACE_Accept_QoS_Params qos_params,
153 ACE_Addr *remote_addr = 0,
154 ACE_Time_Value *timeout = 0,
155 bool restart = true,
156 bool reset_new_handle = false) const;
158 private:
159 /// The filename prefix of the created mmap files. It should
160 /// contains the absolute path name of the file.
161 ACE_TCHAR *mmap_prefix_;
163 /// A cached MALLOC_OPTIONS. MEM_Accaptor use it to create the shared
164 /// mamory malloc upon every incoming connection.
165 ACE_MEM_SAP::MALLOC_OPTIONS malloc_options_;
167 /// Preferred signaling strategy.
168 ACE_MEM_IO::Signal_Strategy preferred_strategy_;
171 ACE_END_VERSIONED_NAMESPACE_DECL
173 #if defined (__ACE_INLINE__)
174 #include "ace/MEM_Acceptor.inl"
175 #endif /* __ACE_INLINE__ */
177 #endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
179 #include /**/ "ace/post.h"
180 #endif /* ACE_MEM_ACCEPTOR_H */