3 //=============================================================================
5 * @file SOCK_SEQPACK_Connector.h
7 * $Id: SOCK_SEQPACK_Connector.h 80826 2008-03-04 14:51:23Z wotte $
9 * @author Patrick J. Lardieri <plardier@atl.lmco.com>
10 * @author Gaurav Naik, Lockheed Martin ATL
11 * @author based on SOCK_STREAM_Connector
12 * by Douglas C. Schmidt <schmidt@dre.vanderbilt.edu>
15 //=============================================================================
17 #ifndef ACE_SOCK_SEQPACK_CONNECTOR_H
18 #define ACE_SOCK_SEQPACK_CONNECTOR_H
20 #include /**/ "ace/pre.h"
22 #include /**/ "ace/ACE_export.h"
24 #include "ace/SOCK_SEQPACK_Association.h"
25 #include "ace/Multihomed_INET_Addr.h"
27 #if !defined (ACE_LACKS_PRAGMA_ONCE)
29 #endif /* ACE_LACKS_PRAGMA_ONCE */
31 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
33 // Forward declarations.
37 * @class ACE_SOCK_SEQPACK_Connector
39 * @brief Defines a factory that actively connects to a remote IP
40 * address and TCP port, creating a new @c ACE_SOCK_SEQPACK_Association object.
42 * The @c ACE_SOCK_SEQPACK_Connector doesn't have a socket of its own,
43 * i.e., it simply "borrows" the one from the @c ACE_SOCK_SEQPACK_Association
44 * that's being connected. The reason for this is that the
45 * underlying socket API doesn't use a factory socket to connect
46 * data mode sockets. Therefore, there's no need to inherit
47 * @c ACE_SOCK_SEQPACK_Connector from @c ACE_SOCK. A nice side-effect of
48 * this is that @c ACE_SOCK_SEQPACK_Connector objects do not store state so
49 * they can be used reentrantly in multithreaded programs.
51 class ACE_Export ACE_SOCK_SEQPACK_Connector
54 // = Initialization and termination methods.
55 /// Default constructor.
56 ACE_SOCK_SEQPACK_Connector (void);
59 * Actively connect to a peer, producing a connected @c ACE_SOCK_SEQPACK_Association
60 * object if the connection succeeds.
62 * @param new_association The @c ACE_SOCK_SEQPACK_Association object that will be connected
64 * @param remote_sap The address that we are trying to connect to.
65 * The protocol family of @c remote_sap is used for
66 * the connected socket. That is, if @c remote_sap
67 * contains an IPv6 address, a socket with family
68 * PF_INET6 will be used, else it will be PF_INET.
69 * @param timeout Pointer to an @c ACE_Time_Value object with amount
70 * of time to wait to connect. If the pointer is 0
71 * then the call blocks until the connection attempt
72 * is complete, whether it succeeds or fails. If
73 * *timeout == {0, 0} then the connection is done
74 * using nonblocking mode. In this case, if the
75 * connection can't be made immediately, this method
76 * returns -1 and errno == EWOULDBLOCK.
77 * If *timeout > {0, 0} then this is the maximum amount
78 * of time to wait before timing out; if the specified
79 * amount of time passes before the connection is made,
80 * this method returns -1 and errno == ETIME. Note
81 * the difference between this case and when a blocking
82 * connect is attmpted that TCP times out - in the latter
83 * case, errno will be ETIMEDOUT.
84 * @param local_sap (optional) The local address to bind to. If it's
85 * the default value of @c ACE_Addr::sap_any then the
86 * OS will choose an unused port.
87 * @param reuse_addr (optional) If the value is 1, the local address
88 * (@c local_sap) is reused, even if it hasn't been
90 * @param flags Ignored.
91 * @param perms Ignored.
92 * @param protocol (optional) If value is 0, default SOCK_STREAM
93 * protocol is selected by kernel (typically TCP).
95 * @return Returns 0 if the connection succeeds. If it fails,
96 * -1 is returned and errno contains a specific error
99 ACE_SOCK_SEQPACK_Connector (ACE_SOCK_SEQPACK_Association
&new_association
,
100 const ACE_Addr
&remote_sap
,
101 const ACE_Time_Value
*timeout
= 0,
102 const ACE_Addr
&local_sap
= ACE_Addr::sap_any
,
109 * Actively connect to a peer, producing a connected @c ACE_SOCK_SEQPACK_Association
110 * object if the connection succeeds.
112 * @param new_association The @c ACE_SOCK_SEQPACK_Association object that will be connected
114 * @param remote_sap The address that we are trying to connect to.
115 * The protocol family of @c remote_sap is used for
116 * the connected socket. That is, if @c remote_sap
117 * contains an IPv6 address, a socket with family
118 * PF_INET6 will be used, else it will be PF_INET.
119 * @param timeout Pointer to an @c ACE_Time_Value object with amount
120 * of time to wait to connect. If the pointer is 0
121 * then the call blocks until the connection attempt
122 * is complete, whether it succeeds or fails. If
123 * *timeout == {0, 0} then the connection is done
124 * using nonblocking mode. In this case, if the
125 * connection can't be made immediately, this method
126 * returns -1 and errno == EWOULDBLOCK.
127 * If *timeout > {0, 0} then this is the maximum amount
128 * of time to wait before timing out; if the specified
129 * amount of time passes before the connection is made,
130 * this method returns -1 and errno == ETIME. Note
131 * the difference between this case and when a blocking
132 * connect is attmpted that TCP times out - in the latter
133 * case, errno will be ETIMEDOUT.
134 * @param local_sap (optional) The set of local addresses for SCTP to
136 * @param reuse_addr (optional) If the value is 1, the local address
137 * (@c local_sap) is reused, even if it hasn't been
139 * @param flags Ignored.
140 * @param perms Ignored.
141 * @param protocol (optional) If value is 0, default SOCK_STREAM
142 * protocol is selected by kernel (typically TCP).
144 * @return Returns 0 if the connection succeeds. If it fails,
145 * -1 is returned and errno contains a specific error
148 ACE_SOCK_SEQPACK_Connector (ACE_SOCK_SEQPACK_Association
&new_association
,
149 const ACE_Addr
&remote_sap
,
150 const ACE_Time_Value
*timeout
,
151 const ACE_Multihomed_INET_Addr
&local_sap
,
158 * Actively connect to a peer, producing a connected @c ACE_SOCK_SEQPACK_Association
159 * object if the connection succeeds.
161 * @param new_association The @c ACE_SOCK_SEQPACK_Association object that will be connected
163 * @param remote_sap The address that we are trying to connect to.
164 * The protocol family of @c remote_sap is used for
165 * the connected socket. That is, if @c remote_sap
166 * contains an IPv6 address, a socket with family
167 * PF_INET6 will be used, else it will be PF_INET.
168 * @param timeout Pointer to an @c ACE_Time_Value object with amount
169 * of time to wait to connect. If the pointer is 0
170 * then the call blocks until the connection attempt
171 * is complete, whether it succeeds or fails. If
172 * *timeout == {0, 0} then the connection is done
173 * using nonblocking mode. In this case, if the
174 * connection can't be made immediately, this method
175 * returns -1 and errno == EWOULDBLOCK.
176 * If *timeout > {0, 0} then this is the maximum amount
177 * of time to wait before timing out; if the specified
178 * amount of time passes before the connection is made,
179 * this method returns -1 and errno == ETIME. Note
180 * the difference between this case and when a blocking
181 * connect is attmpted that TCP times out - in the latter
182 * case, errno will be ETIMEDOUT.
183 * @param local_sap (optional) The local address to bind to. If it's
184 * the default value of @c ACE_Addr::sap_any then the
185 * OS will choose an unused port.
186 * @param reuse_addr (optional) If the value is 1, the local address
187 * (@c local_sap) is reused, even if it hasn't been
189 * @param flags Ignored.
190 * @param perms Ignored.
191 * @param protocol (optional) If value is 0, default SOCK_STREAM
192 * protocol is selected by kernel (typically TCP).
194 * @return Returns 0 if the connection succeeds. If it fails,
195 * -1 is returned and errno contains a specific error
198 int connect (ACE_SOCK_SEQPACK_Association
&new_association
,
199 const ACE_Addr
&remote_sap
,
200 const ACE_Time_Value
*timeout
= 0,
201 const ACE_Addr
&local_sap
= ACE_Addr::sap_any
,
208 * Actively connect to a peer, producing a connected @c ACE_SOCK_SEQPACK_Association
209 * object if the connection succeeds.
211 * @param new_association The @c ACE_SOCK_SEQPACK_Association object that will be connected
213 * @param remote_sap The address that we are trying to connect to.
214 * The protocol family of @c remote_sap is used for
215 * the connected socket. That is, if @c remote_sap
216 * contains an IPv6 address, a socket with family
217 * PF_INET6 will be used, else it will be PF_INET.
218 * @param timeout Pointer to an @c ACE_Time_Value object with amount
219 * of time to wait to connect. If the pointer is 0
220 * then the call blocks until the connection attempt
221 * is complete, whether it succeeds or fails. If
222 * *timeout == {0, 0} then the connection is done
223 * using nonblocking mode. In this case, if the
224 * connection can't be made immediately, this method
225 * returns -1 and errno == EWOULDBLOCK.
226 * If *timeout > {0, 0} then this is the maximum amount
227 * of time to wait before timing out; if the specified
228 * amount of time passes before the connection is made,
229 * this method returns -1 and errno == ETIME. Note
230 * the difference between this case and when a blocking
231 * connect is attmpted that TCP times out - in the latter
232 * case, errno will be ETIMEDOUT.
233 * @param local_sap (optional) The set of local addresses for SCTP to
235 * @param reuse_addr (optional) If the value is 1, the local address
236 * (@c local_sap) is reused, even if it hasn't been
238 * @param flags Ignored.
239 * @param perms Ignored.
240 * @param protocol (optional) If value is 0, default SOCK_STREAM
241 * protocol is selected by kernel (typically TCP).
243 * @return Returns 0 if the connection succeeds. If it fails,
244 * -1 is returned and errno contains a specific error
248 int connect (ACE_SOCK_SEQPACK_Association
&new_association
,
249 const ACE_Addr
&remote_sap
,
250 const ACE_Time_Value
*timeout
,
251 const ACE_Multihomed_INET_Addr
&local_sap
,
258 ~ACE_SOCK_SEQPACK_Connector (void);
260 // = Completion routine.
262 * Try to complete a nonblocking connection that was begun by a
263 * previous call to connect with a {0, 0} ACE_Time_Value timeout.
266 * @param new_association The @c ACE_SOCK_SEQPACK_Association object that will be connected
268 * @param remote_sap If non-0, it points to the @c ACE_INET_Addr object
269 * that will contain the address of the connected peer.
270 * @param timeout Same values and return value possibilites as for
271 * connect(). @see connect().
273 int complete (ACE_SOCK_SEQPACK_Association
&new_association
,
274 ACE_Addr
*remote_sap
= 0,
275 const ACE_Time_Value
*timeout
= 0);
277 /// Resets any event associations on this handle
278 int reset_new_handle (ACE_HANDLE handle
);
281 typedef ACE_Multihomed_INET_Addr PEER_ADDR
;
282 typedef ACE_SOCK_SEQPACK_Association PEER_STREAM
;
284 /// Dump the state of an object.
285 void dump (void) const;
287 /// Declare the dynamic allocation hooks.
288 ACE_ALLOC_HOOK_DECLARE
;
291 /// Perform operations that ensure the socket is opened using
292 /// BSD-style semantics (no QoS).
293 int shared_open (ACE_SOCK_SEQPACK_Association
&new_association
,
298 /// Perform operations that ensure the socket is opened using
299 /// QoS-enabled semantics.
300 int shared_open (ACE_SOCK_SEQPACK_Association
&new_association
,
303 ACE_Protocol_Info
*protocolinfo
,
308 /// Perform operations that must be called before <ACE_OS::connect>.
309 int shared_connect_start (ACE_SOCK_SEQPACK_Association
&new_association
,
310 const ACE_Time_Value
*timeout
,
311 const ACE_Addr
&local_sap
);
313 int shared_connect_start (ACE_SOCK_SEQPACK_Association
&new_association
,
314 const ACE_Time_Value
*timeout
,
315 const ACE_Multihomed_INET_Addr
&local_sap
);
317 /// Perform operations that must be called after <ACE_OS::connect>.
318 int shared_connect_finish (ACE_SOCK_SEQPACK_Association
&new_association
,
319 const ACE_Time_Value
*timeout
,
323 ACE_END_VERSIONED_NAMESPACE_DECL
325 #if defined (__ACE_INLINE__)
326 #include "ace/SOCK_SEQPACK_Connector.inl"
327 #endif /* __ACE_INLINE__ */
329 #include /**/ "ace/post.h"
331 #endif /* ACE_SOCK_SEQPACK_CONNECTOR_H */