summaryrefslogtreecommitdiff
path: root/ace/MEM_IO.cpp
diff options
context:
space:
mode:
authornanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-02-16 04:58:45 +0000
committernanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-02-16 04:58:45 +0000
commit156eeb190c9006bd9f829c9df0baf9dfad06ed5b (patch)
treeb14548001390ba594bc81d52feecc7c193aa28a2 /ace/MEM_IO.cpp
parent007152fac08efe3ba9c637731aa076132cdb21e4 (diff)
downloadATCD-156eeb190c9006bd9f829c9df0baf9dfad06ed5b.tar.gz
ChangeLogTag:Tue Feb 15 22:57:59 2000 Nanbor Wang <nanbor@cs.wustl.edu>
Diffstat (limited to 'ace/MEM_IO.cpp')
-rw-r--r--ace/MEM_IO.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/ace/MEM_IO.cpp b/ace/MEM_IO.cpp
index 3b0b8867043..7d6d5361aa8 100644
--- a/ace/MEM_IO.cpp
+++ b/ace/MEM_IO.cpp
@@ -24,6 +24,49 @@ ACE_MEM_IO::dump (void) const
// socket, allocates a buffer of this size, reads in the data, and
// returns the number of bytes read.
+ssize_t
+ACE_MEM_IO::send (const ACE_Message_Block *message_block,
+ const ACE_Time_Value *timeout)
+{
+ ACE_TRACE ("ACE_MEM_IO::send");
+
+ ssize_t len = message_block->total_length ();
+
+ if (len != 0)
+ {
+ char *buf = ACE_static_cast (char *, this->acquire_buffer (len));
+ ssize_t n = 0;
+ while (message_block != 0)
+ {
+ ACE_OS::memcpy (buf + n,
+ message_block->rd_ptr (),
+ message_block->length ());
+ n += message_block->length ();
+
+ if (message_block->cont ())
+ message_block = message_block->cont ();
+ else
+ message_block = message_block->next ();
+ }
+
+ off_t offset = this->set_buf_len (buf, len);
+ if (ACE::send (this->get_handle (),
+ (const char *) &offset,
+ sizeof (offset),
+ 0,
+ timeout) != sizeof (offset))
+ {
+ // unsucessful send, release the memory in the shared-memory.
+ this->release_buffer (buf);
+
+ return -1;
+ }
+ return len;
+ }
+ return 0;
+}
+
+
#if 0
ssize_t
ACE_MEM_IO::recvv (iovec *io_vec,