*Backed out changeset 3be01fb200a5

--HG--
branch : trunk
This commit is contained in:
maximius
2009-10-17 15:51:44 -07:00
parent 26b5e033ff
commit e585187b24
2257 changed files with 103863 additions and 761 deletions
+26
View File
@@ -1,16 +1,23 @@
// $Id: SOCK_IO.cpp 82294 2008-07-12 13:03:37Z johnnyw $
#include "ace/SOCK_IO.h"
#include "ace/Handle_Set.h"
#include "ace/OS_NS_sys_select.h"
#include "ace/OS_NS_sys_socket.h"
#include "ace/OS_Memory.h"
#include "ace/Truncate.h"
#if !defined (__ACE_INLINE__)
#include "ace/SOCK_IO.inl"
#endif /* __ACE_INLINE__ */
ACE_RCSID(ace, SOCK_IO, "$Id: SOCK_IO.cpp 82294 2008-07-12 13:03:37Z johnnyw $")
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_ALLOC_HOOK_DEFINE(ACE_SOCK_IO)
void
ACE_SOCK_IO::dump (void) const
{
@@ -18,10 +25,12 @@ ACE_SOCK_IO::dump (void) const
ACE_TRACE ("ACE_SOCK_IO::dump");
#endif /* ACE_HAS_DUMP */
}
// Allows a client to read from a socket without having to provide
// a buffer to read. This method determines how much data is in the
// socket, allocates a buffer of this size, reads in the data, and
// returns the number of bytes read.
ssize_t
ACE_SOCK_IO::recvv (iovec *io_vec,
const ACE_Time_Value *timeout) const
@@ -31,7 +40,9 @@ ACE_SOCK_IO::recvv (iovec *io_vec,
ACE_Handle_Set handle_set;
handle_set.reset ();
handle_set.set_bit (this->get_handle ());
io_vec->iov_base = 0;
// Check the status of the current socket.
int select_width;
# if defined (ACE_WIN32)
@@ -57,7 +68,9 @@ ACE_SOCK_IO::recvv (iovec *io_vec,
// Goes fine, fallthrough to get data
break;
}
int inlen = 0;
if (ACE_OS::ioctl (this->get_handle (),
FIONREAD,
&inlen) == -1)
@@ -85,14 +98,17 @@ ACE_SOCK_IO::recvv (iovec *io_vec,
ACE_NOTSUP_RETURN (-1);
#endif /* FIONREAD */
}
// Send N char *ptrs and int lengths. Note that the char *'s precede
// the ints (basically, an varargs version of writev). The count N is
// the *total* number of trailing arguments, *not* a couple of the
// number of tuple pairs!
ssize_t
ACE_SOCK_IO::send (size_t n, ...) const
{
ACE_TRACE ("ACE_SOCK_IO::send");
va_list argp;
int const total_tuples = ACE_Utils::truncate_cast<int> (n / 2);
iovec *iovp = 0;
@@ -103,12 +119,15 @@ ACE_SOCK_IO::send (size_t n, ...) const
iovec[total_tuples],
-1);
#endif /* !defined (ACE_HAS_ALLOCA) */
va_start (argp, n);
for (int i = 0; i < total_tuples; i++)
{
iovp[i].iov_base = va_arg (argp, char *);
iovp[i].iov_len = va_arg (argp, int);
}
ssize_t const result = ACE_OS::sendv (this->get_handle (),
iovp,
total_tuples);
@@ -118,15 +137,18 @@ ACE_SOCK_IO::send (size_t n, ...) const
va_end (argp);
return result;
}
// This is basically an interface to ACE_OS::readv, that doesn't use
// the struct iovec_Base explicitly. The ... can be passed as an arbitrary
// number of (char *ptr, int len) tuples. However, the count N is the
// *total* number of trailing arguments, *not* a couple of the number
// of tuple pairs!
ssize_t
ACE_SOCK_IO::recv (size_t n, ...) const
{
ACE_TRACE ("ACE_SOCK_IO::recv");
va_list argp;
int const total_tuples = ACE_Utils::truncate_cast<int> (n / 2);
iovec *iovp;
@@ -137,12 +159,15 @@ ACE_SOCK_IO::recv (size_t n, ...) const
iovec[total_tuples],
-1);
#endif /* !defined (ACE_HAS_ALLOCA) */
va_start (argp, n);
for (int i = 0; i < total_tuples; i++)
{
iovp[i].iov_base = va_arg (argp, char *);
iovp[i].iov_len = va_arg (argp, int);
}
ssize_t const result = ACE_OS::recvv (this->get_handle (),
iovp,
total_tuples);
@@ -152,5 +177,6 @@ ACE_SOCK_IO::recv (size_t n, ...) const
va_end (argp);
return result;
}
ACE_END_VERSIONED_NAMESPACE_DECL