#include <SOCK_SEQPACK_Association.h>
Inheritance diagram for ACE_SOCK_SEQPACK_Association:


Public Types | |
| typedef ACE_Multihomed_INET_Addr | PEER_ADDR |
Public Member Functions | |
| ACE_SOCK_SEQPACK_Association (void) | |
| Constructor. | |
| ACE_SOCK_SEQPACK_Association (ACE_HANDLE h) | |
| Constructor (sets the underlying ACE_HANDLE with ). | |
| ~ACE_SOCK_SEQPACK_Association (void) | |
| Destructor. | |
| int | get_local_addrs (ACE_INET_Addr *addrs, size_t &size) const |
| int | get_remote_addrs (ACE_INET_Addr *addrs, size_t &size) const |
| ssize_t | recv_n (void *buf, size_t len, int flags, const ACE_Time_Value *timeout=0, size_t *bytes_transferred=0) const |
| Try to recv exactly bytes into from the connected socket. | |
| ssize_t | recv_n (void *buf, size_t len, const ACE_Time_Value *timeout=0, size_t *bytes_transferred=0) const |
| Try to recv exactly bytes into from the connected socket. | |
| ssize_t | recvv_n (iovec iov[], int iovcnt, const ACE_Time_Value *timeout=0, size_t *bytes_transferred=0) const |
| Receive an of size from the connected socket. | |
| ssize_t | send_n (const void *buf, size_t len, int flags, const ACE_Time_Value *timeout=0, size_t *bytes_transferred=0) const |
| Try to send exactly bytes from to the connection socket. | |
| ssize_t | send_n (const void *buf, size_t len, const ACE_Time_Value *timeout=0, size_t *bytes_transferred=0) const |
| Try to send exactly bytes from to the connected socket. | |
| ssize_t | send_n (const ACE_Message_Block *message_block, const ACE_Time_Value *timeout=0, size_t *bytes_transferred=0) const |
| ssize_t | sendv_n (const iovec iov[], int iovcnt, const ACE_Time_Value *timeout=0, size_t *bytes_transferred=0) const |
| Send an of size to the connected socket. | |
| ssize_t | send_urg (const void *ptr, size_t len=sizeof(char), const ACE_Time_Value *timeout=0) const |
| ssize_t | recv_urg (void *ptr, size_t len=sizeof(char), const ACE_Time_Value *timeout=0) const |
| int | close_reader (void) |
| Close down the reader. | |
| int | close_writer (void) |
| Close down the writer. | |
| int | close (void) |
| int | abort (void) |
| void | dump (void) const |
| Dump the state of an object. | |
Public Attributes | |
| ACE_ALLOC_HOOK_DECLARE | |
| Declare the dynamic allocation hooks. | |
This adds additional wrapper methods atop the class.
is the buffer to write from or receive into. is the number of bytes to transfer. The parameter in the following methods indicates how long to blocking trying to transfer data. If == 0, then the call behaves as a normal send/recv call, i.e., for blocking sockets, the call will block until action is possible; for non-blocking sockets, EWOULDBLOCK will be returned if no action is immediately possible. If != 0, the call will wait for data to arrive no longer than the relative time specified in *. The "_n()" I/O methods keep looping until all the data has been transferred. These methods also work for sockets in non-blocking mode i.e., they keep looping on EWOULDBLOCK. is used to make sure we keep making progress, i.e., the same timeout value is used for every I/O operation in the loop and the timeout is not counted down. The return values for the "*_n()" methods match the return values from the non "_n()" methods and are specified as follows:
On partial transfers, i.e., if any data is transferred before timeout/error/EOF, will contain the number of bytes transferred. Methods with parameter are I/O vector variants of the I/O operations. Methods with the extra argument will always result in getting called. Methods without the extra argument will result in getting called on Win32 platforms, and getting called on non-Win32 platforms.
Definition at line 78 of file SOCK_SEQPACK_Association.h.
|
|
Definition at line 185 of file SOCK_SEQPACK_Association.h. |
|
|
Constructor.
Definition at line 11 of file SOCK_SEQPACK_Association.inl.
00012 {
00013 // ACE_TRACE ("ACE_SOCK_SEQPACK_Association::ACE_SOCK_SEQPACK_Association");
00014 }
|
|
|
Constructor (sets the underlying ACE_HANDLE with ).
Definition at line 17 of file SOCK_SEQPACK_Association.inl. References ACE_IPC_SAP::set_handle().
00018 {
00019 // ACE_TRACE ("ACE_SOCK_SEQPACK_Association::ACE_SOCK_SEQPACK_Association");
00020 this->set_handle (h);
00021 }
|
|
|
Destructor.
Definition at line 24 of file SOCK_SEQPACK_Association.inl.
00025 {
00026 // ACE_TRACE ("ACE_SOCK_SEQPACK_Association::~ACE_SOCK_SEQPACK_Association");
00027 }
|
|
|
Abort the association according to RFC 2960 9.1 through the API in draft-ietf-tsvwg-sctpsocket-09 7.1.4. Definition at line 48 of file SOCK_SEQPACK_Association.cpp. References close(), and ACE_OS::setsockopt().
00049 {
00050 //
00051 // setsockopt() SO_LINGER configures socket to reap immediately.
00052 // Normal close then aborts the association.
00053 //
00054 linger slinger;
00055
00056 slinger.l_onoff = 1;
00057 slinger.l_linger = 0;
00058
00059 if (-1 == ACE_OS::setsockopt (this->get_handle (),
00060 SOL_SOCKET,
00061 SO_LINGER,
00062 reinterpret_cast<const char *> (&slinger),
00063 sizeof (linger)))
00064 {
00065 return -1;
00066 }
00067
00068 return this->close ();
00069 }
|
|
|
Close down the socket (we need this to make things work correctly on Win32, which requires use to do a before doing the close to avoid losing data). Reimplemented from ACE_SOCK. Definition at line 29 of file SOCK_SEQPACK_Association.cpp. References ACE_SOCK::close(), and close_writer(). Referenced by abort(), ACE_SOCK_SEQPACK_Connector::complete(), ACE_SOCK_SEQPACK_Connector::shared_connect_finish(), and ACE_SOCK_SEQPACK_Connector::shared_connect_start().
00030 {
00031 #if defined (ACE_WIN32)
00032 // We need the following call to make things work correctly on
00033 // Win32, which requires use to do a <close_writer> before doing the
00034 // close in order to avoid losing data. Note that we don't need to
00035 // do this on UNIX since it doesn't have this "feature". Moreover,
00036 // this will cause subtle problems on UNIX due to the way that
00037 // fork() works.
00038 this->close_writer ();
00039 #endif /* ACE_WIN32 */
00040 // Close down the socket.
00041 return ACE_SOCK::close ();
00042 }
|
|
|
Close down the reader.
Definition at line 30 of file SOCK_SEQPACK_Association.inl. References ACE_SHUTDOWN_READ, ACE_TRACE, ACE_IPC_SAP::get_handle(), and ACE_OS::shutdown().
00031 {
00032 ACE_TRACE ("ACE_SOCK_SEQPACK_Association::close_reader");
00033 if (this->get_handle () != ACE_INVALID_HANDLE)
00034 return ACE_OS::shutdown (this->get_handle (), ACE_SHUTDOWN_READ);
00035 else
00036 return 0;
00037 }
|
|
|
Close down the writer.
Definition at line 42 of file SOCK_SEQPACK_Association.inl. References ACE_SHUTDOWN_WRITE, ACE_TRACE, ACE_IPC_SAP::get_handle(), and ACE_OS::shutdown(). Referenced by close().
00043 {
00044 ACE_TRACE ("ACE_SOCK_SEQPACK_Association::close_writer");
00045 if (this->get_handle () != ACE_INVALID_HANDLE)
00046 return ACE_OS::shutdown (this->get_handle (), ACE_SHUTDOWN_WRITE);
00047 else
00048 return 0;
00049 }
|
|
|
Dump the state of an object.
Reimplemented from ACE_SOCK_IO. Definition at line 21 of file SOCK_SEQPACK_Association.cpp. References ACE_TRACE.
00022 {
00023 #if defined (ACE_HAS_DUMP)
00024 ACE_TRACE ("ACE_SOCK_SEQPACK_Association::dump");
00025 #endif /* ACE_HAS_DUMP */
00026 }
|
|
||||||||||||
|
Return local endpoint addresses in the referenced array of ACE_INET_Addr, which should have the specified . If the number of local endpoint addresses is less than , then will be set to this number. If successful, the method returns 0, otherwise returns -1. Definition at line 72 of file SOCK_SEQPACK_Association.cpp. References ACE_NEW_RETURN, ACE_TRACE, ACE_Auto_Basic_Array_Ptr< X >::get(), ACE_OS::getsockname(), ACE_OS::memset(), ACE_Auto_Basic_Array_Ptr< X >::reset(), ACE_INET_Addr::set_addr(), ACE_Addr::set_size(), and ACE_Addr::set_type().
00073 {
00074 ACE_TRACE ("ACE_SOCK_SEQPACK_Association::get_local_addrs");
00075
00076 #if defined (ACE_HAS_LKSCTP)
00077 /*
00078 The size of ACE_INET_Addr must be large enough to hold the number of
00079 local addresses on the machine. If the array is too small, the function
00080 will only return the number of addresses that will fit. If the array is
00081 too large, the 'size' parameter will be modified to indicate the number
00082 of addrs.
00083
00084 We will call sctp_getladdrs() which accepts 3 parameters
00085 1. a socket fd
00086 2. a sctp association_id which will be ignored since we are using
00087 tcp sockets
00088 3. a pointer to sockaddr
00089
00090 lksctp/draft will allocate memory and we are responsible for freeing
00091 it by calling sctp_freeladdrs().
00092 */
00093
00094 sockaddr_in *si = 0;
00095 sockaddr *laddrs = 0;
00096 int err = 0;
00097 size_t len = 0;
00098
00099 err = sctp_getladdrs(this->get_handle(), 0, &laddrs);
00100 if (err > 0)
00101 {
00102 len = err;
00103 // check to see if we have more addresses than we have
00104 // space in our ACE_INET_Addr array
00105 if (len > size)
00106 {
00107 // since our array is too small, we will only copy the first
00108 // few that fit
00109 len = size;
00110 }
00111
00112 for (size_t i = 0; i < len; i++)
00113 {
00114 // first we cast the sockaddr to sockaddr_in
00115 // since we only support ipv4 at this time.
00116 si = (sockaddr_in *) (&(laddrs[i]));
00117
00118 // now we fillup the ace_inet_addr array
00119 addrs[i].set_addr(si, sizeof(sockaddr_in));
00120 addrs[i].set_type(si->sin_family);
00121 addrs[i].set_size(sizeof(sockaddr_in));
00122 }
00123 }
00124 else /* err < 0 */
00125 {
00126 // sctp_getladdrs will return -1 on error
00127 return -1;
00128 }
00129
00130 // indicate the num of addrs returned to the calling function
00131 size = len;
00132
00133 // make sure we free the struct using the system function
00134 sctp_freeladdrs(laddrs);
00135
00136 #else
00137
00138 /*
00139 We will be calling ACE_OS::getsockname, which accepts (and
00140 potentially modifies) two reference parameters:
00141
00142 1. a sockaddr_in* that points to a buffer
00143 2. an int* that points to the size of this buffer
00144
00145 The OpenSS7 implementation of SCTP copies an array of ipv4
00146 sockaddr_in into the buffer. Then, if the size of the buffer is
00147 greater than the size used, the size parameter is reduced
00148 accordingly.
00149
00150 */
00151
00152 // The array of sockaddr_in will be stored in an ACE_Auto_Array_Ptr,
00153 // which causes dynamically-allocated memory to be released as soon
00154 // as the ACE_Auto_Array_Ptr goes out of scope.
00155 ACE_Auto_Array_Ptr<sockaddr_in> addr_structs;
00156
00157 // Allocate memory for this array. Return -1 if the memory cannot
00158 // be allocated. (This activity requires a temporary variable---a
00159 // bare sockaddr_in* --- because ACE_NEW_RETURN cannot act directory on
00160 // an ACE_Auto_Array_Ptr.)
00161 {
00162 sockaddr_in *addr_structs_bootstrap = 0;
00163 ACE_NEW_RETURN (addr_structs_bootstrap, sockaddr_in[size], -1);
00164 addr_structs.reset(addr_structs_bootstrap);
00165 }
00166
00167 // Physical size of this array is its logical size multiplied by
00168 // the physical size of one of its elements.
00169 size_t physical_size = size * sizeof(sockaddr_in);
00170
00171 /* Clear the array */
00172 ACE_OS::memset(addr_structs.get(),
00173 0,
00174 physical_size);
00175
00176 /*
00177 ** Populate the array with real values from the getsockname system
00178 ** call. addr_structs is modified, and name_size is modified to contain
00179 ** the number of bytes written to addr_structs.
00180 ** Use name_size to get the data types right across the call.
00181 */
00182 int name_size = static_cast<int> (physical_size);
00183 if (ACE_OS::getsockname (this->get_handle (),
00184 reinterpret_cast<sockaddr *> (addr_structs.get()),
00185 &name_size) == -1)
00186 return -1;
00187
00188 /* Calculate the NEW physical size of the array */
00189 name_size /= sizeof (sockaddr_in);
00190 size = static_cast<size_t> (name_size);
00191
00192 /* Copy each sockaddr_in to the address structure of an ACE_Addr from
00193 the passed-in array */
00194 const int addrlen (static_cast<int> (sizeof (sockaddr_in)));
00195 for (int i = 0; i < name_size; ++i)
00196 {
00197 addrs[i].set_addr (&(addr_structs[i]), addrlen);
00198 addrs[i].set_type (addr_structs[i].sin_family);
00199 addrs[i].set_size (addrlen);
00200 }
00201 #endif /* ACE_HAS_LKSCTP */
00202 return 0;
00203 }
|
|
||||||||||||
|
Return remote endpoint addresses in the referenced array of ACE_INET_Addr, which should have the specified . If the number of remote endpoint addresses is less than , then will be set to this number. If successful, the method returns 0, otherwise returns -1. Definition at line 207 of file SOCK_SEQPACK_Association.cpp. References ACE_NEW_RETURN, ACE_TRACE, ACE_Auto_Basic_Array_Ptr< X >::get(), ACE_OS::getpeername(), ACE_OS::memset(), ACE_Auto_Basic_Array_Ptr< X >::reset(), ACE_INET_Addr::set_addr(), ACE_Addr::set_size(), and ACE_Addr::set_type().
00208 {
00209 ACE_TRACE ("ACE_SOCK_SEQPACK_Association::get_remote_addrs");
00210 #if defined (ACE_HAS_LKSCTP)
00211 /*
00212 The size of ACE_INET_Addr must be large enough to hold the number of
00213 remotes addresses in the association. If the array is too small, the
00214 function will only return the number of addresses that will fit. If the
00215 array is too large, the 'size' parameter will be modified to indicate
00216 the number of addrs.
00217
00218 We will call sctp_getpaddrs() which accepts 3 parameters
00219 1. a socket fd
00220 2. a sctp association_id which will be ignored since we are using
00221 tcp sockets
00222 3. a pointer to a sockaddr
00223
00224 lksctp/draft will allocate memory and we are responsible for freeing
00225 it by calling sctp_freepaddrs().
00226 */
00227
00228 sockaddr_in *si = 0;
00229 sockaddr *paddrs = 0;
00230 int err = 0;
00231 size_t len = 0;
00232
00233 err = sctp_getpaddrs(this->get_handle(), 0, &paddrs);
00234 if (err > 0)
00235 {
00236 len = err;
00237 // check to see if we have more addresses than we have
00238 // space in our ACE_INET_Addr array
00239 if (len > size)
00240 {
00241 // since our array is too small, we will only copy the first
00242 // few that fit
00243 len = size;
00244 }
00245
00246 for (size_t i = 0; i < len; i++)
00247 {
00248 // first we cast the sockaddr to sockaddr_in
00249 // since we only support ipv4 at this time.
00250 si = (sockaddr_in *) (&(paddrs[i]));
00251
00252 // now we fillup the ace_inet_addr array
00253 addrs[i].set_addr(si, sizeof(sockaddr_in));
00254 addrs[i].set_type(si->sin_family);
00255 addrs[i].set_size(sizeof(sockaddr_in));
00256 }
00257 }
00258 else /* err < 0 */
00259 {
00260 // sctp_getpaddrs will return -1 on error
00261 return -1;
00262 }
00263
00264 // indicate the num of addrs returned to the calling function
00265 size = len;
00266
00267 // make sure we free the struct using the system function
00268 sctp_freepaddrs(paddrs);
00269
00270 #else
00271
00272 /*
00273 We will be calling ACE_OS::getpeername, which accepts (and
00274 potentially modifies) two reference parameters:
00275
00276 1. a sockaddr_in* that points to a buffer
00277 2. an int* that points to the size of this buffer
00278
00279 The OpenSS7 implementation of SCTP copies an array of ipv4
00280 sockaddr_in into the buffer. Then, if the size of the buffer is
00281 greater than the size used, the size parameter is reduced
00282 accordingly.
00283
00284 */
00285
00286 // The array of sockaddr_in will be stored in an ACE_Auto_Array_Ptr,
00287 // which causes dynamically-allocated memory to be released as soon
00288 // as the ACE_Auto_Array_Ptr goes out of scope.
00289 ACE_Auto_Array_Ptr<sockaddr_in> addr_structs;
00290
00291 // Allocate memory for this array. Return -1 if the memory cannot
00292 // be allocated. (This activity requires a temporary variable---a
00293 // bare sockaddr_in* --- because ACE_NEW_RETURN cannot act directory on
00294 // an ACE_Auto_Array_Ptr.)
00295 {
00296 sockaddr_in *addr_structs_bootstrap = 0;
00297 ACE_NEW_RETURN (addr_structs_bootstrap, sockaddr_in[size], -1);
00298 addr_structs.reset(addr_structs_bootstrap);
00299 }
00300
00301 // Physical size of this array is its logical size multiplied by
00302 // the physical size of one of its elements.
00303 size_t physical_size = size * sizeof(sockaddr_in);
00304
00305 /* Clear the array */
00306 ACE_OS::memset(addr_structs.get(),
00307 0,
00308 physical_size);
00309
00310 /*
00311 ** Populate the array with real values from the getpeername system
00312 ** call. addr_structs is modified, and name_size is modified to contain
00313 ** the number of bytes written to addr_structs.
00314 ** Use name_size to get the data types right across the call.
00315 */
00316 int name_size = static_cast<int> (physical_size);
00317 if (ACE_OS::getpeername (this->get_handle (),
00318 reinterpret_cast<sockaddr *> (addr_structs.get()),
00319 &name_size) == -1)
00320 return -1;
00321
00322 /* Calculate the NEW physical size of the array */
00323 name_size /= sizeof (sockaddr_in);
00324 size = static_cast<size_t> (name_size);
00325
00326 /* Copy each sockaddr_in to the address structure of an ACE_Addr from
00327 the passed-in array */
00328 const int addrlen (static_cast<int> (sizeof (sockaddr_in)));
00329 for (int i = 0; i < name_size; ++i)
00330 {
00331 addrs[i].set_addr (&(addr_structs[i]), addrlen);
00332 addrs[i].set_type (addr_structs[i].sin_family);
00333 addrs[i].set_size (addrlen);
00334 }
00335 #endif /* ACE_HAS_LKSCTP */
00336 return 0;
00337 }
|
|
||||||||||||||||||||
|
Try to recv exactly bytes into from the connected socket.
Definition at line 68 of file SOCK_SEQPACK_Association.inl. References ACE_TRACE, and ACE::recv_n().
00072 {
00073 ACE_TRACE ("ACE_SOCK_SEQPACK_Association::recv_n");
00074 return ACE::recv_n (this->get_handle (),
00075 buf,
00076 len,
00077 timeout,
00078 bytes_transferred);
00079 }
|
|
||||||||||||||||||||||||
|
Try to recv exactly bytes into from the connected socket.
Definition at line 52 of file SOCK_SEQPACK_Association.inl. References ACE_TRACE, and ACE::recv_n().
00057 {
00058 ACE_TRACE ("ACE_SOCK_SEQPACK_Association::recv_n");
00059 return ACE::recv_n (this->get_handle (),
00060 buf,
00061 len,
00062 flags,
00063 timeout,
00064 bytes_transferred);
00065 }
|
|
||||||||||||||||
|
Definition at line 165 of file SOCK_SEQPACK_Association.inl. References ACE_TRACE, and ACE::recv().
|
|
||||||||||||||||||||
|
Receive an of size from the connected socket.
Definition at line 82 of file SOCK_SEQPACK_Association.inl. References ACE_TRACE, and ACE::recvv_n().
00086 {
00087 ACE_TRACE ("ACE_SOCK_SEQPACK_Association::recvv_n");
00088 return ACE::recvv_n (this->get_handle (),
00089 iov,
00090 n,
00091 timeout,
00092 bytes_transferred);
00093 }
|
|
||||||||||||||||
|
Send all the s chained through their and pointers. This call uses the underlying OS gather-write operation to reduce the domain-crossing penalty. Definition at line 140 of file SOCK_SEQPACK_Association.inl. References ACE_TRACE, and ACE::send_n().
00143 {
00144 ACE_TRACE ("ACE_SOCK_SEQPACK_Association::send_n");
00145 return ACE::send_n (this->get_handle (),
00146 message_block,
00147 timeout,
00148 bytes_transferred);
00149 }
|
|
||||||||||||||||||||
|
Try to send exactly bytes from to the connected socket.
Definition at line 112 of file SOCK_SEQPACK_Association.inl. References ACE_TRACE, and ACE::send_n().
00116 {
00117 ACE_TRACE ("ACE_SOCK_SEQPACK_Association::send_n");
00118 return ACE::send_n (this->get_handle (),
00119 buf,
00120 len,
00121 timeout,
00122 bytes_transferred);
00123 }
|
|
||||||||||||||||||||||||
|
Try to send exactly bytes from to the connection socket.
Definition at line 96 of file SOCK_SEQPACK_Association.inl. References ACE_TRACE, and ACE::send_n().
00101 {
00102 ACE_TRACE ("ACE_SOCK_SEQPACK_Association::send_n");
00103 return ACE::send_n (this->get_handle (),
00104 buf,
00105 len,
00106 flags,
00107 timeout,
00108 bytes_transferred);
00109 }
|
|
||||||||||||||||
|
Definition at line 152 of file SOCK_SEQPACK_Association.inl. References ACE_TRACE, and ACE::send().
|
|
||||||||||||||||||||
|
Send an of size to the connected socket.
Definition at line 126 of file SOCK_SEQPACK_Association.inl. References ACE_TRACE, and ACE::sendv_n().
00130 {
00131 ACE_TRACE ("ACE_SOCK_SEQPACK_Association::sendv_n");
00132 return ACE::sendv_n (this->get_handle (),
00133 iov,
00134 n,
00135 timeout,
00136 bytes_transferred);
00137 }
|
|
|
Declare the dynamic allocation hooks.
Reimplemented from ACE_SOCK_IO. Definition at line 191 of file SOCK_SEQPACK_Association.h. |
1.3.6