00001
00002
00003 #include "ace/FIFO_Send_Msg.h"
00004
00005 #include "ace/Log_Msg.h"
00006 #include "ace/OS_NS_sys_uio.h"
00007
00008 #if !defined (__ACE_INLINE__)
00009 #include "ace/FIFO_Send_Msg.inl"
00010 #endif
00011
00012 ACE_RCSID(ace, FIFO_Send_Msg, "$Id: FIFO_Send_Msg.cpp 79134 2007-07-31 18:23:50Z johnnyw $")
00013
00014 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00015
00016 ACE_ALLOC_HOOK_DEFINE(ACE_FIFO_Send_Msg)
00017
00018 void
00019 ACE_FIFO_Send_Msg::dump (void) const
00020 {
00021 #if defined (ACE_HAS_DUMP)
00022 ACE_TRACE ("ACE_FIFO_Send_Msg::dump");
00023 ACE_FIFO_Send::dump ();
00024 #endif
00025 }
00026
00027 ssize_t
00028 ACE_FIFO_Send_Msg::send (const ACE_Str_Buf &send_msg)
00029 {
00030
00031 #if defined (ACE_HAS_STREAM_PIPES)
00032 if (ACE_OS::putmsg (this->get_handle (),
00033 (strbuf *) 0,
00034 (strbuf *) &send_msg,
00035 0) == -1)
00036 return -1;
00037 else
00038 return send_msg.len;
00039 #else
00040 iovec iov[2];
00041
00042 iov[0].iov_base = (char *) &send_msg.len;
00043 iov[0].iov_len = sizeof send_msg.len;
00044
00045 iov[1].iov_base = (char *) send_msg.buf;
00046 iov[1].iov_len = static_cast<u_long> (send_msg.len);
00047
00048 ssize_t sent = ACE_OS::writev (this->get_handle (), iov, 2);
00049 if (sent > 0)
00050 sent -= iov[0].iov_len;
00051 return sent;
00052 #endif
00053 }
00054
00055 ACE_FIFO_Send_Msg::ACE_FIFO_Send_Msg (void)
00056 {
00057
00058 }
00059
00060 int
00061 ACE_FIFO_Send_Msg::open (const ACE_TCHAR *fifo_name,
00062 int flags,
00063 mode_t perms,
00064 LPSECURITY_ATTRIBUTES sa)
00065 {
00066 ACE_TRACE ("ACE_FIFO_Send_Msg::open");
00067 return ACE_FIFO_Send::open (fifo_name, flags | O_WRONLY, perms, sa);
00068 }
00069
00070 ACE_FIFO_Send_Msg::ACE_FIFO_Send_Msg (const ACE_TCHAR *fifo_name,
00071 int flags,
00072 mode_t perms,
00073 LPSECURITY_ATTRIBUTES sa)
00074 {
00075 ACE_TRACE ("ACE_FIFO_Send_Msg::ACE_FIFO_Send_Msg");
00076 if (this->ACE_FIFO_Send_Msg::open (fifo_name, flags, perms, sa) == -1)
00077 ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_FIFO_Send_Msg")));
00078 }
00079
00080 ACE_END_VERSIONED_NAMESPACE_DECL