00001
00002
00003 #include "ace/SPIPE_Stream.h"
00004 #include "ace/OS_Memory.h"
00005
00006 #if !defined (__ACE_INLINE__)
00007 #include "ace/SPIPE_Stream.inl"
00008 #endif
00009
00010 ACE_RCSID(ace, SPIPE_Stream, "$Id: SPIPE_Stream.cpp 69051 2005-10-28 16:14:56Z ossama $")
00011
00012 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00013
00014 ACE_ALLOC_HOOK_DEFINE(ACE_SPIPE_Stream)
00015
00016 void
00017 ACE_SPIPE_Stream::dump (void) const
00018 {
00019 #if defined (ACE_HAS_DUMP)
00020 ACE_TRACE ("ACE_SPIPE_Stream::dump");
00021 #endif
00022 }
00023
00024
00025
00026 ACE_SPIPE_Stream::ACE_SPIPE_Stream (void)
00027 {
00028
00029 }
00030
00031
00032
00033
00034
00035
00036 ssize_t
00037 ACE_SPIPE_Stream::send (size_t n, ...) const
00038 {
00039
00040 va_list argp;
00041 int total_tuples = static_cast<int> (n / 2);
00042 iovec *iovp;
00043 #if defined (ACE_HAS_ALLOCA)
00044 iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
00045 #else
00046 ACE_NEW_RETURN (iovp,
00047 iovec[total_tuples],
00048 -1);
00049 #endif
00050
00051 va_start (argp, n);
00052
00053 for (int i = 0; i < total_tuples; i++)
00054 {
00055 iovp[i].iov_base = va_arg (argp, char *);
00056 iovp[i].iov_len = va_arg (argp, int);
00057 }
00058
00059 ssize_t result = ACE_OS::writev (this->get_handle (), iovp, total_tuples);
00060 #if !defined (ACE_HAS_ALLOCA)
00061 delete [] iovp;
00062 #endif
00063 va_end (argp);
00064 return result;
00065 }
00066
00067
00068
00069
00070
00071
00072
00073 ssize_t
00074 ACE_SPIPE_Stream::recv (size_t n, ...) const
00075 {
00076 ACE_TRACE ("ACE_SPIPE_Stream::recv");
00077 va_list argp;
00078 int total_tuples = static_cast<int> (n / 2);
00079 iovec *iovp;
00080 #if defined (ACE_HAS_ALLOCA)
00081 iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
00082 #else
00083 ACE_NEW_RETURN (iovp,
00084 iovec[total_tuples],
00085 -1);
00086 #endif
00087
00088 va_start (argp, n);
00089
00090 for (int i = 0; i < total_tuples; i++)
00091 {
00092 iovp[i].iov_base = va_arg (argp, char *);
00093 iovp[i].iov_len = va_arg (argp, int);
00094 }
00095
00096 ssize_t result = ACE_OS::readv (this->get_handle (), iovp, total_tuples);
00097 #if !defined (ACE_HAS_ALLOCA)
00098 delete [] iovp;
00099 #endif
00100 va_end (argp);
00101 return result;
00102 }
00103
00104 ACE_END_VERSIONED_NAMESPACE_DECL