diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-09-18 05:50:48 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-09-18 05:50:48 +0000 |
commit | b3eab516c833716db9dda1758189aafc7f20f386 (patch) | |
tree | a9e6c2de2e539483a58595e85940a74156e45a87 /ace/ACE.cpp | |
parent | bace4247479755e955f23648b56128e23b7a8dd1 (diff) | |
download | ATCD-b3eab516c833716db9dda1758189aafc7f20f386.tar.gz |
*** empty log message ***
Diffstat (limited to 'ace/ACE.cpp')
-rw-r--r-- | ace/ACE.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/ace/ACE.cpp b/ace/ACE.cpp index ba3caa669a1..a36c9a1e381 100644 --- a/ace/ACE.cpp +++ b/ace/ACE.cpp @@ -474,6 +474,77 @@ ACE::basename (const wchar_t *pathname, wchar_t delim) } #endif /* ACE_HAS_UNICODE */ +// 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::send (ACE_HANDLE handle, size_t n, ...) +{ + ACE_TRACE ("ACE_SOCK_IO::send"); + + va_list argp; + size_t total_tuples = n / 2; + iovec *iovp; +#if defined (ACE_HAS_ALLOCA) + iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); +#else + ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); +#endif /* !defined (ACE_HAS_ALLOCA) */ + + va_start (argp, n); + + for (size_t i = 0; i < total_tuples; i++) + { + iovp[i].iov_base = va_arg (argp, char *); + iovp[i].iov_len = va_arg (argp, int); + } + + ssize_t result = ACE_OS::writev (handle, iovp, total_tuples); +#if !defined (ACE_HAS_ALLOCA) + delete [] iovp; +#endif /* !defined (ACE_HAS_ALLOCA) */ + va_end (argp); + return result; +} + +// This is basically an interface to ACE_OS::readv, that doesn't use +// the struct iovec 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::recv (ACE_HANDLE handle, size_t n, ...) +{ + ACE_TRACE ("ACE_SOCK_IO::recv"); + + va_list argp; + size_t total_tuples = n / 2; + iovec *iovp; +#if defined (ACE_HAS_ALLOCA) + iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); +#else + ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); +#endif /* !defined (ACE_HAS_ALLOCA) */ + + va_start (argp, n); + + for (size_t i = 0; i < total_tuples; i++) + { + iovp[i].iov_base = va_arg (argp, char *); + iovp[i].iov_len = va_arg (argp, int); + } + + ssize_t result = ACE_OS::readv (handle, iovp, total_tuples); +#if !defined (ACE_HAS_ALLOCA) + delete [] iovp; +#endif /* !defined (ACE_HAS_ALLOCA) */ + va_end (argp); + return result; +} + // Miscellaneous static methods used throughout ACE. ssize_t |