3 //=============================================================================
6 * @file SOCK_SEQPACK_Association.h
8 * @author Patrick J. Lardieri <plardier@atl.lmco.com>
9 * @author Gaurav Naik, Lockheed Martin ATL
10 * @author based on SOCK_Stream
11 * by Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
13 //=============================================================================
15 #ifndef ACE_SOCK_SEQPACK_ASSOCIATION_H
16 #define ACE_SOCK_SEQPACK_ASSOCIATION_H
18 #include /**/ "ace/pre.h"
20 #include /**/ "ace/ACE_export.h"
22 #if !defined (ACE_LACKS_PRAGMA_ONCE)
24 #endif /* ACE_LACKS_PRAGMA_ONCE */
26 #include "ace/SOCK_IO.h"
27 #include "ace/Multihomed_INET_Addr.h"
29 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
31 // Forward declarations.
32 class ACE_Message_Block
;
35 * @class ACE_SOCK_SEQPACK_Association
37 * @brief Defines the methods in the ACE_SOCK_SEQPACK_Association abstraction.
39 * This adds additional wrapper methods atop the <ACE_SOCK_IO>
42 * @a buf is the buffer to write from or receive into.
43 * @a len is the number of bytes to transfer.
44 * The @a timeout parameter in the following methods indicates how
45 * long to blocking trying to transfer data. If @a timeout == 0,
46 * then the call behaves as a normal send/recv call, i.e., for
47 * blocking sockets, the call will block until action is possible;
48 * for non-blocking sockets, EWOULDBLOCK will be returned if no
49 * action is immediately possible.
50 * If @a timeout != 0, the call will wait for data to arrive no longer
51 * than the relative time specified in *@a timeout.
52 * The "_n()" I/O methods keep looping until all the data has been
53 * transferred. These methods also work for sockets in non-blocking
54 * mode i.e., they keep looping on EWOULDBLOCK. @a timeout is used
55 * to make sure we keep making progress, i.e., the same timeout
56 * value is used for every I/O operation in the loop and the timeout
57 * is not counted down.
58 * The return values for the "*_n()" methods match the return values
59 * from the non "_n()" methods and are specified as follows:
60 * - On complete transfer, the number of bytes transferred is returned.
61 * - On timeout, -1 is returned, errno == ETIME.
62 * - On error, -1 is returned, errno is set to appropriate error.
63 * - On EOF, 0 is returned, errno is irrelevant.
65 * On partial transfers, i.e., if any data is transferred before
66 * timeout/error/EOF, <bytes_transferred> will contain the number of
68 * Methods with <iovec> parameter are I/O vector variants of the I/O
70 * Methods with the extra @a flags argument will always result in
71 * <send> getting called. Methods without the extra @a flags argument
72 * will result in <send> getting called on Win32 platforms, and
73 * <write> getting called on non-Win32 platforms.
75 class ACE_Export ACE_SOCK_SEQPACK_Association
: public ACE_SOCK_IO
78 // Initialization and termination methods.
80 ACE_SOCK_SEQPACK_Association ();
82 /// Constructor (sets the underlying ACE_HANDLE with <h>).
83 ACE_SOCK_SEQPACK_Association (ACE_HANDLE h
);
86 ~ACE_SOCK_SEQPACK_Association ();
89 * Return local endpoint addresses in the referenced array of
90 * ACE_INET_Addr, which should have the specified @a size. If the
91 * number of local endpoint addresses is less than @a size, then
92 * @a size will be set to this number. If successful, the method
93 * returns 0, otherwise returns -1.
95 int get_local_addrs (ACE_INET_Addr
*addrs
, size_t &size
) const;
98 * Return remote endpoint addresses in the referenced array of
99 * ACE_INET_Addr, which should have the specified @a size. If the
100 * number of remote endpoint addresses is less than @a size, then
101 * @a size will be set to this number. If successful, the method
102 * returns 0, otherwise returns -1.
104 int get_remote_addrs (ACE_INET_Addr
*addrs
, size_t &size
) const;
108 /// Try to recv exactly @a len bytes into @a buf from the connected socket.
109 ssize_t
recv_n (void *buf
,
112 const ACE_Time_Value
*timeout
= 0,
113 size_t *bytes_transferred
= 0) const;
115 /// Try to recv exactly @a len bytes into @a buf from the connected socket.
116 ssize_t
recv_n (void *buf
,
118 const ACE_Time_Value
*timeout
= 0,
119 size_t *bytes_transferred
= 0) const;
121 /// Receive an <iovec> of size <iovcnt> from the connected socket.
122 ssize_t
recvv_n (iovec iov
[],
124 const ACE_Time_Value
*timeout
= 0,
125 size_t *bytes_transferred
= 0) const;
127 /// Try to send exactly @a len bytes from @a buf to the connection socket.
128 ssize_t
send_n (const void *buf
,
131 const ACE_Time_Value
*timeout
= 0,
132 size_t *bytes_transferred
= 0) const;
134 /// Try to send exactly @a len bytes from @a buf to the connected socket.
135 ssize_t
send_n (const void *buf
,
137 const ACE_Time_Value
*timeout
= 0,
138 size_t *bytes_transferred
= 0) const;
140 /// Send all the @a message_blocks chained through their <next> and
141 /// <cont> pointers. This call uses the underlying OS gather-write
142 /// operation to reduce the domain-crossing penalty.
143 ssize_t
send_n (const ACE_Message_Block
*message_block
,
144 const ACE_Time_Value
*timeout
= 0,
145 size_t *bytes_transferred
= 0) const;
147 /// Send an <iovec> of size <iovcnt> to the connected socket.
148 ssize_t
sendv_n (const iovec iov
[],
150 const ACE_Time_Value
*timeout
= 0,
151 size_t *bytes_transferred
= 0) const;
153 // = Send/receive ``urgent'' data (see TCP specs...).
154 ssize_t
send_urg (const void *ptr
,
155 size_t len
= sizeof (char),
156 const ACE_Time_Value
*timeout
= 0) const;
158 ssize_t
recv_urg (void *ptr
,
159 size_t len
= sizeof (char),
160 const ACE_Time_Value
*timeout
= 0) const;
162 // = Selectively close endpoints.
163 /// Close down the reader.
166 /// Close down the writer.
170 * Close down the socket (we need this to make things work correctly
171 * on Win32, which requires use to do a <close_writer> before doing
172 * the close to avoid losing data). */
176 * Abort the association according to RFC 2960 9.1 through the API
177 * in draft-ietf-tsvwg-sctpsocket-09 7.1.4.
182 typedef ACE_Multihomed_INET_Addr PEER_ADDR
;
184 /// Dump the state of an object.
187 /// Declare the dynamic allocation hooks.
188 ACE_ALLOC_HOOK_DECLARE
;
191 ACE_END_VERSIONED_NAMESPACE_DECL
193 #if defined (__ACE_INLINE__)
194 #include "ace/SOCK_SEQPACK_Association.inl"
195 #endif /* __ACE_INLINE__ */
197 #include /**/ "ace/post.h"
199 #endif /* ACE_SOCK_SEQPACK_ASSOCIATION_H */