Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / SOCK_SEQPACK_Connector.h
blob23e3475c9ee6dc432705fe86265a323dc021ead3
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file SOCK_SEQPACK_Connector.h
7 * @author Patrick J. Lardieri <plardier@atl.lmco.com>
8 * @author Gaurav Naik, Lockheed Martin ATL
9 * @author based on SOCK_STREAM_Connector
10 * by Douglas C. Schmidt <schmidt@dre.vanderbilt.edu>
12 //=============================================================================
14 #ifndef ACE_SOCK_SEQPACK_CONNECTOR_H
15 #define ACE_SOCK_SEQPACK_CONNECTOR_H
17 #include /**/ "ace/pre.h"
19 #include /**/ "ace/ACE_export.h"
21 #include "ace/SOCK_SEQPACK_Association.h"
22 #include "ace/Multihomed_INET_Addr.h"
24 #if !defined (ACE_LACKS_PRAGMA_ONCE)
25 # pragma once
26 #endif /* ACE_LACKS_PRAGMA_ONCE */
28 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
30 // Forward declarations.
31 class ACE_Time_Value;
33 /**
34 * @class ACE_SOCK_SEQPACK_Connector
36 * @brief Defines a factory that actively connects to a remote IP
37 * address and TCP port, creating a new @c ACE_SOCK_SEQPACK_Association object.
39 * The @c ACE_SOCK_SEQPACK_Connector doesn't have a socket of its own,
40 * i.e., it simply "borrows" the one from the @c ACE_SOCK_SEQPACK_Association
41 * that's being connected. The reason for this is that the
42 * underlying socket API doesn't use a factory socket to connect
43 * data mode sockets. Therefore, there's no need to inherit
44 * @c ACE_SOCK_SEQPACK_Connector from @c ACE_SOCK. A nice side-effect of
45 * this is that @c ACE_SOCK_SEQPACK_Connector objects do not store state so
46 * they can be used reentrantly in multithreaded programs.
48 class ACE_Export ACE_SOCK_SEQPACK_Connector
50 public:
51 /// Default constructor.
52 ACE_SOCK_SEQPACK_Connector ();
54 /**
55 * Actively connect to a peer, producing a connected @c ACE_SOCK_SEQPACK_Association
56 * object if the connection succeeds.
58 * @param new_association The @c ACE_SOCK_SEQPACK_Association object that will be connected
59 * to the peer.
60 * @param remote_sap The address that we are trying to connect to.
61 * The protocol family of @c remote_sap is used for
62 * the connected socket. That is, if @c remote_sap
63 * contains an IPv6 address, a socket with family
64 * PF_INET6 will be used, else it will be PF_INET.
65 * @param timeout Pointer to an @c ACE_Time_Value object with amount
66 * of time to wait to connect. If the pointer is 0
67 * then the call blocks until the connection attempt
68 * is complete, whether it succeeds or fails. If
69 * *timeout == {0, 0} then the connection is done
70 * using nonblocking mode. In this case, if the
71 * connection can't be made immediately, this method
72 * returns -1 and errno == EWOULDBLOCK.
73 * If *timeout > {0, 0} then this is the maximum amount
74 * of time to wait before timing out; if the specified
75 * amount of time passes before the connection is made,
76 * this method returns -1 and errno == ETIME. Note
77 * the difference between this case and when a blocking
78 * connect is attempted that TCP times out - in the latter
79 * case, errno will be ETIMEDOUT.
80 * @param local_sap (optional) The local address to bind to. If it's
81 * the default value of @c ACE_Addr::sap_any then the
82 * OS will choose an unused port.
83 * @param reuse_addr (optional) If the value is 1, the local address
84 * (@c local_sap) is reused, even if it hasn't been
85 * cleaned up yet.
86 * @param flags Ignored.
87 * @param perms Ignored.
88 * @param protocol (optional) If value is 0, default SOCK_STREAM
89 * protocol is selected by kernel (typically TCP).
91 * @return Returns 0 if the connection succeeds. If it fails,
92 * -1 is returned and errno contains a specific error
93 * code.
95 ACE_SOCK_SEQPACK_Connector (ACE_SOCK_SEQPACK_Association &new_association,
96 const ACE_Addr &remote_sap,
97 const ACE_Time_Value *timeout = 0,
98 const ACE_Addr &local_sap = ACE_Addr::sap_any,
99 int reuse_addr = 0,
100 int flags = 0,
101 int perms = 0,
102 int protocol = 132);
105 * Actively connect to a peer, producing a connected @c ACE_SOCK_SEQPACK_Association
106 * object if the connection succeeds.
108 * @param new_association The @c ACE_SOCK_SEQPACK_Association object that will be connected
109 * to the peer.
110 * @param remote_sap The address that we are trying to connect to.
111 * The protocol family of @c remote_sap is used for
112 * the connected socket. That is, if @c remote_sap
113 * contains an IPv6 address, a socket with family
114 * PF_INET6 will be used, else it will be PF_INET.
115 * @param timeout Pointer to an @c ACE_Time_Value object with amount
116 * of time to wait to connect. If the pointer is 0
117 * then the call blocks until the connection attempt
118 * is complete, whether it succeeds or fails. If
119 * *timeout == {0, 0} then the connection is done
120 * using nonblocking mode. In this case, if the
121 * connection can't be made immediately, this method
122 * returns -1 and errno == EWOULDBLOCK.
123 * If *timeout > {0, 0} then this is the maximum amount
124 * of time to wait before timing out; if the specified
125 * amount of time passes before the connection is made,
126 * this method returns -1 and errno == ETIME. Note
127 * the difference between this case and when a blocking
128 * connect is attempted that TCP times out - in the latter
129 * case, errno will be ETIMEDOUT.
130 * @param local_sap (optional) The set of local addresses for SCTP to
131 * bind to.
132 * @param reuse_addr (optional) If the value is 1, the local address
133 * (@c local_sap) is reused, even if it hasn't been
134 * cleaned up yet.
135 * @param flags Ignored.
136 * @param perms Ignored.
137 * @param protocol (optional) If value is 0, default SOCK_STREAM
138 * protocol is selected by kernel (typically TCP).
140 * @return Returns 0 if the connection succeeds. If it fails,
141 * -1 is returned and errno contains a specific error
142 * code.
144 ACE_SOCK_SEQPACK_Connector (ACE_SOCK_SEQPACK_Association &new_association,
145 const ACE_Addr &remote_sap,
146 const ACE_Time_Value *timeout,
147 const ACE_Multihomed_INET_Addr &local_sap,
148 int reuse_addr = 0,
149 int flags = 0,
150 int perms = 0,
151 int protocol = 132);
154 * Actively connect to a peer, producing a connected @c ACE_SOCK_SEQPACK_Association
155 * object if the connection succeeds.
157 * @param new_association The @c ACE_SOCK_SEQPACK_Association object that will be connected
158 * to the peer.
159 * @param remote_sap The address that we are trying to connect to.
160 * The protocol family of @c remote_sap is used for
161 * the connected socket. That is, if @c remote_sap
162 * contains an IPv6 address, a socket with family
163 * PF_INET6 will be used, else it will be PF_INET.
164 * @param timeout Pointer to an @c ACE_Time_Value object with amount
165 * of time to wait to connect. If the pointer is 0
166 * then the call blocks until the connection attempt
167 * is complete, whether it succeeds or fails. If
168 * *timeout == {0, 0} then the connection is done
169 * using nonblocking mode. In this case, if the
170 * connection can't be made immediately, this method
171 * returns -1 and errno == EWOULDBLOCK.
172 * If *timeout > {0, 0} then this is the maximum amount
173 * of time to wait before timing out; if the specified
174 * amount of time passes before the connection is made,
175 * this method returns -1 and errno == ETIME. Note
176 * the difference between this case and when a blocking
177 * connect is attempted that TCP times out - in the latter
178 * case, errno will be ETIMEDOUT.
179 * @param local_sap (optional) The local address to bind to. If it's
180 * the default value of @c ACE_Addr::sap_any then the
181 * OS will choose an unused port.
182 * @param reuse_addr (optional) If the value is 1, the local address
183 * (@c local_sap) is reused, even if it hasn't been
184 * cleaned up yet.
185 * @param flags Ignored.
186 * @param perms Ignored.
187 * @param protocol (optional) If value is 0, default SOCK_STREAM
188 * protocol is selected by kernel (typically TCP).
190 * @return Returns 0 if the connection succeeds. If it fails,
191 * -1 is returned and errno contains a specific error
192 * code.
194 int connect (ACE_SOCK_SEQPACK_Association &new_association,
195 const ACE_Addr &remote_sap,
196 const ACE_Time_Value *timeout = 0,
197 const ACE_Addr &local_sap = ACE_Addr::sap_any,
198 int reuse_addr = 0,
199 int flags = 0,
200 int perms = 0,
201 int protocol = 132);
204 * Actively connect to a peer, producing a connected @c ACE_SOCK_SEQPACK_Association
205 * object if the connection succeeds.
207 * @param new_association The @c ACE_SOCK_SEQPACK_Association object that will be connected
208 * to the peer.
209 * @param remote_sap The address that we are trying to connect to.
210 * The protocol family of @c remote_sap is used for
211 * the connected socket. That is, if @c remote_sap
212 * contains an IPv6 address, a socket with family
213 * PF_INET6 will be used, else it will be PF_INET.
214 * @param timeout Pointer to an @c ACE_Time_Value object with amount
215 * of time to wait to connect. If the pointer is 0
216 * then the call blocks until the connection attempt
217 * is complete, whether it succeeds or fails. If
218 * *timeout == {0, 0} then the connection is done
219 * using nonblocking mode. In this case, if the
220 * connection can't be made immediately, this method
221 * returns -1 and errno == EWOULDBLOCK.
222 * If *timeout > {0, 0} then this is the maximum amount
223 * of time to wait before timing out; if the specified
224 * amount of time passes before the connection is made,
225 * this method returns -1 and errno == ETIME. Note
226 * the difference between this case and when a blocking
227 * connect is attempted that TCP times out - in the latter
228 * case, errno will be ETIMEDOUT.
229 * @param local_sap (optional) The set of local addresses for SCTP to
230 * bind to.
231 * @param reuse_addr (optional) If the value is 1, the local address
232 * (@c local_sap) is reused, even if it hasn't been
233 * cleaned up yet.
234 * @param flags Ignored.
235 * @param perms Ignored.
236 * @param protocol (optional) If value is 0, default SOCK_STREAM
237 * protocol is selected by kernel (typically TCP).
239 * @return Returns 0 if the connection succeeds. If it fails,
240 * -1 is returned and errno contains a specific error
241 * code.
244 int connect (ACE_SOCK_SEQPACK_Association &new_association,
245 const ACE_Addr &remote_sap,
246 const ACE_Time_Value *timeout,
247 const ACE_Multihomed_INET_Addr &local_sap,
248 int reuse_addr = 0,
249 int flags = 0,
250 int perms = 0,
251 int protocol = 132);
253 /// Default dtor.
254 ~ACE_SOCK_SEQPACK_Connector ();
256 // = Completion routine.
258 * Try to complete a nonblocking connection that was begun by a
259 * previous call to connect with a {0, 0} ACE_Time_Value timeout.
260 * @see connect().
262 * @param new_association The @c ACE_SOCK_SEQPACK_Association object that will be connected
263 * to the peer.
264 * @param remote_sap If non-0, it points to the @c ACE_INET_Addr object
265 * that will contain the address of the connected peer.
266 * @param timeout Same values and return value possibilities as for
267 * connect(). @see connect().
269 int complete (ACE_SOCK_SEQPACK_Association &new_association,
270 ACE_Addr *remote_sap = 0,
271 const ACE_Time_Value *timeout = 0);
273 /// Resets any event associations on this handle
274 bool reset_new_handle (ACE_HANDLE handle);
276 // = Meta-type info
277 typedef ACE_Multihomed_INET_Addr PEER_ADDR;
278 typedef ACE_SOCK_SEQPACK_Association PEER_STREAM;
280 /// Dump the state of an object.
281 void dump () const;
283 /// Declare the dynamic allocation hooks.
284 ACE_ALLOC_HOOK_DECLARE;
286 protected:
287 /// Perform operations that ensure the socket is opened using
288 /// BSD-style semantics (no QoS).
289 int shared_open (ACE_SOCK_SEQPACK_Association &new_association,
290 int protocol_family,
291 int protocol,
292 int reuse_addr);
294 /// Perform operations that ensure the socket is opened using
295 /// QoS-enabled semantics.
296 int shared_open (ACE_SOCK_SEQPACK_Association &new_association,
297 int protocol_family,
298 int protocol,
299 ACE_Protocol_Info *protocolinfo,
300 ACE_SOCK_GROUP g,
301 u_long flags,
302 int reuse_addr);
304 /// Perform operations that must be called before <ACE_OS::connect>.
305 int shared_connect_start (ACE_SOCK_SEQPACK_Association &new_association,
306 const ACE_Time_Value *timeout,
307 const ACE_Addr &local_sap);
309 int shared_connect_start (ACE_SOCK_SEQPACK_Association &new_association,
310 const ACE_Time_Value *timeout,
311 const ACE_Multihomed_INET_Addr &local_sap);
313 /// Perform operations that must be called after <ACE_OS::connect>.
314 int shared_connect_finish (ACE_SOCK_SEQPACK_Association &new_association,
315 const ACE_Time_Value *timeout,
316 int result);
319 ACE_END_VERSIONED_NAMESPACE_DECL
321 #if defined (__ACE_INLINE__)
322 #include "ace/SOCK_SEQPACK_Connector.inl"
323 #endif /* __ACE_INLINE__ */
325 #include /**/ "ace/post.h"
327 #endif /* ACE_SOCK_SEQPACK_CONNECTOR_H */