1 // $Id: DEV_IO.cpp 80826 2008-03-04 14:51:23Z wotte $
3 #include "ace/DEV_IO.h"
4 #include "ace/Log_Msg.h"
6 #if !defined (__ACE_INLINE__)
7 #include "ace/DEV_IO.inl"
8 #endif /* __ACE_INLINE__ */
10 ACE_RCSID(ace
, DEV_IO
, "$Id: DEV_IO.cpp 80826 2008-03-04 14:51:23Z wotte $")
13 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
15 ACE_ALLOC_HOOK_DEFINE(ACE_DEV_IO
)
17 // Return the local endpoint address.
20 ACE_DEV_IO::get_local_addr (ACE_DEV_Addr
&addr
) const
22 ACE_TRACE ("ACE_DEV_IO::get_local_addr");
28 // Return the address of the remotely connected peer (if there is
32 ACE_DEV_IO::get_remote_addr (ACE_DEV_Addr
&addr
) const
34 ACE_TRACE ("ACE_DEV_IO::get_remote_addr");
40 ACE_DEV_IO::dump (void) const
42 #if defined (ACE_HAS_DUMP)
43 ACE_TRACE ("ACE_DEV_IO::dump");
45 ACE_DEBUG ((LM_DEBUG
, ACE_BEGIN_DUMP
, this));
47 ACE_DEBUG ((LM_DEBUG
, ACE_END_DUMP
));
48 #endif /* ACE_HAS_DUMP */
51 // Simple-minded do nothing constructor.
53 ACE_DEV_IO::ACE_DEV_IO (void)
55 ACE_TRACE ("ACE_DEV_IO::ACE_DEV_IO");
58 // Send N char *ptrs and int lengths. Note that the char *'s precede
59 // the ints (basically, an varargs version of writev). The count N is
60 // the *total* number of trailing arguments, *not* a couple of the
61 // number of tuple pairs!
64 ACE_DEV_IO::send (size_t n
, ...) const
66 ACE_TRACE ("ACE_DEV_IO::send");
68 int total_tuples
= static_cast<int> (n
/ 2);
70 #if defined (ACE_HAS_ALLOCA)
71 iovp
= (iovec
*) alloca (total_tuples
* sizeof (iovec
));
76 #endif /* !defined (ACE_HAS_ALLOCA) */
80 for (int i
= 0; i
< total_tuples
; i
++)
82 iovp
[i
].iov_base
= va_arg (argp
, char *);
83 iovp
[i
].iov_len
= va_arg (argp
, int);
86 ssize_t result
= ACE_OS::writev (this->get_handle (), iovp
, total_tuples
);
87 #if !defined (ACE_HAS_ALLOCA)
89 #endif /* !defined (ACE_HAS_ALLOCA) */
94 // This is basically an interface to ACE_OS::readv, that doesn't use the
95 // struct iovec explicitly. The ... can be passed as an arbitrary
96 // number of (char *ptr, int len) tuples. However, the count N is the
97 // *total* number of trailing arguments, *not* a couple of the number
101 ACE_DEV_IO::recv (size_t n
, ...) const
103 ACE_TRACE ("ACE_DEV_IO::recv");
105 int total_tuples
= static_cast<int> (n
/ 2);
107 #if defined (ACE_HAS_ALLOCA)
108 iovp
= (iovec
*) alloca (total_tuples
* sizeof (iovec
));
110 ACE_NEW_RETURN (iovp
,
113 #endif /* !defined (ACE_HAS_ALLOCA) */
117 for (int i
= 0; i
< total_tuples
; i
++)
119 iovp
[i
].iov_base
= va_arg (argp
, char *);
120 iovp
[i
].iov_len
= va_arg (argp
, int);
123 ssize_t result
= ACE_OS::readv (this->get_handle (), iovp
, total_tuples
);
124 #if !defined (ACE_HAS_ALLOCA)
126 #endif /* !defined (ACE_HAS_ALLOCA) */
131 ACE_END_VERSIONED_NAMESPACE_DECL