3 //=============================================================================
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)
26 #endif /* ACE_LACKS_PRAGMA_ONCE */
28 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
30 // Forward declarations.
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
51 /// Default constructor.
52 ACE_SOCK_SEQPACK_Connector ();
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
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
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
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
,
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
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
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
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
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
,
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
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
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
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
,
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
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
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
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
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
,
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.
262 * @param new_association The @c ACE_SOCK_SEQPACK_Association object that will be connected
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
);
277 typedef ACE_Multihomed_INET_Addr PEER_ADDR
;
278 typedef ACE_SOCK_SEQPACK_Association PEER_STREAM
;
280 /// Dump the state of an object.
283 /// Declare the dynamic allocation hooks.
284 ACE_ALLOC_HOOK_DECLARE
;
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
,
294 /// Perform operations that ensure the socket is opened using
295 /// QoS-enabled semantics.
296 int shared_open (ACE_SOCK_SEQPACK_Association
&new_association
,
299 ACE_Protocol_Info
*protocolinfo
,
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
,
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 */