Defines the methods in the ACE_SOCK_SEQPACK_Association abstraction. More...
#include <SOCK_SEQPACK_Association.h>
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 <h>). | |
~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 len bytes into buf 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 len bytes into buf 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 <iovec> of size <iovcnt> 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 len bytes from buf 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 len bytes from buf 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 <iovec> of size <iovcnt> 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. |
Defines the methods in the ACE_SOCK_SEQPACK_Association abstraction.
This adds additional wrapper methods atop the <ACE_SOCK_IO> class.
buf is the buffer to write from or receive into. len is the number of bytes to transfer. The timeout parameter in the following methods indicates how long to blocking trying to transfer data. If timeout == 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 timeout != 0, the call will wait for data to arrive no longer than the relative time specified in *timeout. 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. timeout 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, <bytes_transferred> will contain the number of bytes transferred. Methods with <iovec> parameter are I/O vector variants of the I/O operations. Methods with the extra flags argument will always result in <send> getting called. Methods without the extra flags argument will result in <send> getting called on Win32 platforms, and <write> 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.
ACE_SOCK_SEQPACK_Association::ACE_SOCK_SEQPACK_Association | ( | void | ) |
Constructor.
Definition at line 11 of file SOCK_SEQPACK_Association.inl.
{
// ACE_TRACE ("ACE_SOCK_SEQPACK_Association::ACE_SOCK_SEQPACK_Association");
}
ACE_SOCK_SEQPACK_Association::ACE_SOCK_SEQPACK_Association | ( | ACE_HANDLE | h | ) |
Constructor (sets the underlying ACE_HANDLE with <h>).
Definition at line 17 of file SOCK_SEQPACK_Association.inl.
{ // ACE_TRACE ("ACE_SOCK_SEQPACK_Association::ACE_SOCK_SEQPACK_Association"); this->set_handle (h); }
ACE_SOCK_SEQPACK_Association::~ACE_SOCK_SEQPACK_Association | ( | void | ) |
Destructor.
Definition at line 24 of file SOCK_SEQPACK_Association.inl.
{
// ACE_TRACE ("ACE_SOCK_SEQPACK_Association::~ACE_SOCK_SEQPACK_Association");
}
int ACE_SOCK_SEQPACK_Association::abort | ( | void | ) |
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.
{ // // setsockopt() SO_LINGER configures socket to reap immediately. // Normal close then aborts the association. // linger slinger; slinger.l_onoff = 1; slinger.l_linger = 0; if (-1 == ACE_OS::setsockopt (this->get_handle (), SOL_SOCKET, SO_LINGER, reinterpret_cast<const char *> (&slinger), sizeof (linger))) { return -1; } return this->close (); }
int ACE_SOCK_SEQPACK_Association::close | ( | void | ) |
Close down the socket (we need this to make things work correctly on Win32, which requires use to do a <close_writer> before doing the close to avoid losing data).
Reimplemented from ACE_SOCK.
Definition at line 29 of file SOCK_SEQPACK_Association.cpp.
{ #if defined (ACE_WIN32) // We need the following call to make things work correctly on // Win32, which requires use to do a <close_writer> before doing the // close in order to avoid losing data. Note that we don't need to // do this on UNIX since it doesn't have this "feature". Moreover, // this will cause subtle problems on UNIX due to the way that // fork() works. this->close_writer (); #endif /* ACE_WIN32 */ // Close down the socket. return ACE_SOCK::close (); }
int ACE_SOCK_SEQPACK_Association::close_reader | ( | void | ) |
Close down the reader.
Definition at line 30 of file SOCK_SEQPACK_Association.inl.
{ ACE_TRACE ("ACE_SOCK_SEQPACK_Association::close_reader"); if (this->get_handle () != ACE_INVALID_HANDLE) return ACE_OS::shutdown (this->get_handle (), ACE_SHUTDOWN_READ); else return 0; }
int ACE_SOCK_SEQPACK_Association::close_writer | ( | void | ) |
Close down the writer.
Definition at line 42 of file SOCK_SEQPACK_Association.inl.
{ ACE_TRACE ("ACE_SOCK_SEQPACK_Association::close_writer"); if (this->get_handle () != ACE_INVALID_HANDLE) return ACE_OS::shutdown (this->get_handle (), ACE_SHUTDOWN_WRITE); else return 0; }
void ACE_SOCK_SEQPACK_Association::dump | ( | void | ) | const |
Dump the state of an object.
Reimplemented from ACE_SOCK_IO.
Definition at line 21 of file SOCK_SEQPACK_Association.cpp.
{ #if defined (ACE_HAS_DUMP) ACE_TRACE ("ACE_SOCK_SEQPACK_Association::dump"); #endif /* ACE_HAS_DUMP */ }
int ACE_SOCK_SEQPACK_Association::get_local_addrs | ( | ACE_INET_Addr * | addrs, | |
size_t & | size | |||
) | const |
Return local endpoint addresses in the referenced array of ACE_INET_Addr, which should have the specified size. If the number of local endpoint addresses is less than size, then size 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.
{ ACE_TRACE ("ACE_SOCK_SEQPACK_Association::get_local_addrs"); #if defined (ACE_HAS_LKSCTP) /* The size of ACE_INET_Addr must be large enough to hold the number of local addresses on the machine. If the array is too small, the function will only return the number of addresses that will fit. If the array is too large, the 'size' parameter will be modified to indicate the number of addrs. We will call sctp_getladdrs() which accepts 3 parameters 1. a socket fd 2. a sctp association_id which will be ignored since we are using tcp sockets 3. a pointer to sockaddr lksctp/draft will allocate memory and we are responsible for freeing it by calling sctp_freeladdrs(). */ sockaddr_in *si = 0; sockaddr *laddrs = 0; int err = 0; size_t len = 0; #ifndef ACE_HAS_VOID_PTR_SCTP_GETLADDRS err = sctp_getladdrs(this->get_handle(), 0, &laddrs); #else err = sctp_getladdrs(this->get_handle(), 0, reinterpret_cast<void**>(&laddrs)); #endif /* ACE_HAS_VOID_PTR_SCTP_GETPADDRS */ if (err > 0) { len = err; // check to see if we have more addresses than we have // space in our ACE_INET_Addr array if (len > size) { // since our array is too small, we will only copy the first // few that fit len = size; } for (size_t i = 0; i < len; i++) { // first we cast the sockaddr to sockaddr_in // since we only support ipv4 at this time. si = (sockaddr_in *) (&(laddrs[i])); // now we fillup the ace_inet_addr array addrs[i].set_addr(si, sizeof(sockaddr_in)); addrs[i].set_type(si->sin_family); addrs[i].set_size(sizeof(sockaddr_in)); } } else /* err < 0 */ { // sctp_getladdrs will return -1 on error return -1; } // indicate the num of addrs returned to the calling function size = len; // make sure we free the struct using the system function sctp_freeladdrs(laddrs); #else /* We will be calling ACE_OS::getsockname, which accepts (and potentially modifies) two reference parameters: 1. a sockaddr_in* that points to a buffer 2. an int* that points to the size of this buffer The OpenSS7 implementation of SCTP copies an array of ipv4 sockaddr_in into the buffer. Then, if the size of the buffer is greater than the size used, the size parameter is reduced accordingly. */ // The array of sockaddr_in will be stored in an ACE_Auto_Array_Ptr, // which causes dynamically-allocated memory to be released as soon // as the ACE_Auto_Array_Ptr goes out of scope. ACE_Auto_Array_Ptr<sockaddr_in> addr_structs; // Allocate memory for this array. Return -1 if the memory cannot // be allocated. (This activity requires a temporary variable---a // bare sockaddr_in* --- because ACE_NEW_RETURN cannot act directory on // an ACE_Auto_Array_Ptr.) { sockaddr_in *addr_structs_bootstrap = 0; ACE_NEW_RETURN (addr_structs_bootstrap, sockaddr_in[size], -1); addr_structs.reset(addr_structs_bootstrap); } // Physical size of this array is its logical size multiplied by // the physical size of one of its elements. size_t physical_size = size * sizeof(sockaddr_in); /* Clear the array */ ACE_OS::memset(addr_structs.get(), 0, physical_size); /* ** Populate the array with real values from the getsockname system ** call. addr_structs is modified, and name_size is modified to contain ** the number of bytes written to addr_structs. ** Use name_size to get the data types right across the call. */ int name_size = static_cast<int> (physical_size); if (ACE_OS::getsockname (this->get_handle (), reinterpret_cast<sockaddr *> (addr_structs.get()), &name_size) == -1) return -1; /* Calculate the NEW physical size of the array */ name_size /= sizeof (sockaddr_in); size = static_cast<size_t> (name_size); /* Copy each sockaddr_in to the address structure of an ACE_Addr from the passed-in array */ const int addrlen (static_cast<int> (sizeof (sockaddr_in))); for (int i = 0; i < name_size; ++i) { addrs[i].set_addr (&(addr_structs[i]), addrlen); addrs[i].set_type (addr_structs[i].sin_family); addrs[i].set_size (addrlen); } #endif /* ACE_HAS_LKSCTP */ return 0; }
int ACE_SOCK_SEQPACK_Association::get_remote_addrs | ( | ACE_INET_Addr * | addrs, | |
size_t & | size | |||
) | const |
Return remote endpoint addresses in the referenced array of ACE_INET_Addr, which should have the specified size. If the number of remote endpoint addresses is less than size, then size will be set to this number. If successful, the method returns 0, otherwise returns -1.
Definition at line 211 of file SOCK_SEQPACK_Association.cpp.
{ ACE_TRACE ("ACE_SOCK_SEQPACK_Association::get_remote_addrs"); #if defined (ACE_HAS_LKSCTP) /* The size of ACE_INET_Addr must be large enough to hold the number of remotes addresses in the association. If the array is too small, the function will only return the number of addresses that will fit. If the array is too large, the 'size' parameter will be modified to indicate the number of addrs. We will call sctp_getpaddrs() which accepts 3 parameters 1. a socket fd 2. a sctp association_id which will be ignored since we are using tcp sockets 3. a pointer to a sockaddr lksctp/draft will allocate memory and we are responsible for freeing it by calling sctp_freepaddrs(). */ sockaddr_in *si = 0; sockaddr *paddrs = 0; int err = 0; size_t len = 0; #ifndef ACE_HAS_VOID_PTR_SCTP_GETPADDRS err = sctp_getpaddrs(this->get_handle(), 0, &paddrs); #else err = sctp_getpaddrs(this->get_handle(), 0, reinterpret_cast<void**>(&paddrs)); #endif /* ACE_HAS_VOID_PTR_SCTP_GETPADDRS */ if (err > 0) { len = err; // check to see if we have more addresses than we have // space in our ACE_INET_Addr array if (len > size) { // since our array is too small, we will only copy the first // few that fit len = size; } for (size_t i = 0; i < len; i++) { // first we cast the sockaddr to sockaddr_in // since we only support ipv4 at this time. si = (sockaddr_in *) (&(paddrs[i])); // now we fillup the ace_inet_addr array addrs[i].set_addr(si, sizeof(sockaddr_in)); addrs[i].set_type(si->sin_family); addrs[i].set_size(sizeof(sockaddr_in)); } } else /* err < 0 */ { // sctp_getpaddrs will return -1 on error return -1; } // indicate the num of addrs returned to the calling function size = len; // make sure we free the struct using the system function sctp_freepaddrs(paddrs); #else /* We will be calling ACE_OS::getpeername, which accepts (and potentially modifies) two reference parameters: 1. a sockaddr_in* that points to a buffer 2. an int* that points to the size of this buffer The OpenSS7 implementation of SCTP copies an array of ipv4 sockaddr_in into the buffer. Then, if the size of the buffer is greater than the size used, the size parameter is reduced accordingly. */ // The array of sockaddr_in will be stored in an ACE_Auto_Array_Ptr, // which causes dynamically-allocated memory to be released as soon // as the ACE_Auto_Array_Ptr goes out of scope. ACE_Auto_Array_Ptr<sockaddr_in> addr_structs; // Allocate memory for this array. Return -1 if the memory cannot // be allocated. (This activity requires a temporary variable---a // bare sockaddr_in* --- because ACE_NEW_RETURN cannot act directory on // an ACE_Auto_Array_Ptr.) { sockaddr_in *addr_structs_bootstrap = 0; ACE_NEW_RETURN (addr_structs_bootstrap, sockaddr_in[size], -1); addr_structs.reset(addr_structs_bootstrap); } // Physical size of this array is its logical size multiplied by // the physical size of one of its elements. size_t physical_size = size * sizeof(sockaddr_in); /* Clear the array */ ACE_OS::memset(addr_structs.get(), 0, physical_size); /* ** Populate the array with real values from the getpeername system ** call. addr_structs is modified, and name_size is modified to contain ** the number of bytes written to addr_structs. ** Use name_size to get the data types right across the call. */ int name_size = static_cast<int> (physical_size); if (ACE_OS::getpeername (this->get_handle (), reinterpret_cast<sockaddr *> (addr_structs.get()), &name_size) == -1) return -1; /* Calculate the NEW physical size of the array */ name_size /= sizeof (sockaddr_in); size = static_cast<size_t> (name_size); /* Copy each sockaddr_in to the address structure of an ACE_Addr from the passed-in array */ const int addrlen (static_cast<int> (sizeof (sockaddr_in))); for (int i = 0; i < name_size; ++i) { addrs[i].set_addr (&(addr_structs[i]), addrlen); addrs[i].set_type (addr_structs[i].sin_family); addrs[i].set_size (addrlen); } #endif /* ACE_HAS_LKSCTP */ return 0; }
ssize_t ACE_SOCK_SEQPACK_Association::recv_n | ( | void * | buf, | |
size_t | len, | |||
const ACE_Time_Value * | timeout = 0 , |
|||
size_t * | bytes_transferred = 0 | |||
) | const |
Try to recv exactly len bytes into buf from the connected socket.
Definition at line 68 of file SOCK_SEQPACK_Association.inl.
{ ACE_TRACE ("ACE_SOCK_SEQPACK_Association::recv_n"); return ACE::recv_n (this->get_handle (), buf, len, timeout, bytes_transferred); }
ssize_t ACE_SOCK_SEQPACK_Association::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 len bytes into buf from the connected socket.
Definition at line 52 of file SOCK_SEQPACK_Association.inl.
{ ACE_TRACE ("ACE_SOCK_SEQPACK_Association::recv_n"); return ACE::recv_n (this->get_handle (), buf, len, flags, timeout, bytes_transferred); }
ssize_t ACE_SOCK_SEQPACK_Association::recv_urg | ( | void * | ptr, | |
size_t | len = sizeof (char) , |
|||
const ACE_Time_Value * | timeout = 0 | |||
) | const |
Definition at line 165 of file SOCK_SEQPACK_Association.inl.
{ ACE_TRACE ("ACE_SOCK_SEQPACK_Association::recv_urg"); return ACE::recv (this->get_handle (), ptr, len, MSG_OOB, timeout); }
ssize_t ACE_SOCK_SEQPACK_Association::recvv_n | ( | iovec | iov[], | |
int | iovcnt, | |||
const ACE_Time_Value * | timeout = 0 , |
|||
size_t * | bytes_transferred = 0 | |||
) | const |
Receive an <iovec> of size <iovcnt> from the connected socket.
Definition at line 82 of file SOCK_SEQPACK_Association.inl.
{ ACE_TRACE ("ACE_SOCK_SEQPACK_Association::recvv_n"); return ACE::recvv_n (this->get_handle (), iov, n, timeout, bytes_transferred); }
ssize_t ACE_SOCK_SEQPACK_Association::send_n | ( | const ACE_Message_Block * | message_block, | |
const ACE_Time_Value * | timeout = 0 , |
|||
size_t * | bytes_transferred = 0 | |||
) | const |
Send all the message_blocks chained through their <next> and <cont> 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.
{ ACE_TRACE ("ACE_SOCK_SEQPACK_Association::send_n"); return ACE::send_n (this->get_handle (), message_block, timeout, bytes_transferred); }
ssize_t ACE_SOCK_SEQPACK_Association::send_n | ( | const void * | buf, | |
size_t | len, | |||
const ACE_Time_Value * | timeout = 0 , |
|||
size_t * | bytes_transferred = 0 | |||
) | const |
Try to send exactly len bytes from buf to the connected socket.
Definition at line 112 of file SOCK_SEQPACK_Association.inl.
{ ACE_TRACE ("ACE_SOCK_SEQPACK_Association::send_n"); return ACE::send_n (this->get_handle (), buf, len, timeout, bytes_transferred); }
ssize_t ACE_SOCK_SEQPACK_Association::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 len bytes from buf to the connection socket.
Definition at line 96 of file SOCK_SEQPACK_Association.inl.
{ ACE_TRACE ("ACE_SOCK_SEQPACK_Association::send_n"); return ACE::send_n (this->get_handle (), buf, len, flags, timeout, bytes_transferred); }
ssize_t ACE_SOCK_SEQPACK_Association::send_urg | ( | const void * | ptr, | |
size_t | len = sizeof (char) , |
|||
const ACE_Time_Value * | timeout = 0 | |||
) | const |
Definition at line 152 of file SOCK_SEQPACK_Association.inl.
{ ACE_TRACE ("ACE_SOCK_SEQPACK_Association::send_urg"); return ACE::send (this->get_handle (), ptr, len, MSG_OOB, timeout); }
ssize_t ACE_SOCK_SEQPACK_Association::sendv_n | ( | const iovec | iov[], | |
int | iovcnt, | |||
const ACE_Time_Value * | timeout = 0 , |
|||
size_t * | bytes_transferred = 0 | |||
) | const |
Send an <iovec> of size <iovcnt> to the connected socket.
Definition at line 126 of file SOCK_SEQPACK_Association.inl.
{ ACE_TRACE ("ACE_SOCK_SEQPACK_Association::sendv_n"); return ACE::sendv_n (this->get_handle (), iov, n, timeout, bytes_transferred); }
Declare the dynamic allocation hooks.
Reimplemented from ACE_SOCK_IO.
Definition at line 191 of file SOCK_SEQPACK_Association.h.