#include <MulticastSendStrategy.h>
Public Member Functions | |
MulticastSendStrategy (MulticastDataLink *link) | |
virtual void | stop_i () |
Let the subclass stop. | |
Protected Member Functions | |
virtual void | prepare_header_i () |
Specific implementation processing of prepared packet header. | |
virtual ssize_t | send_bytes_i (const iovec iov[], int n) |
ssize_t | sync_send (const iovec iov[], int n) |
ssize_t | async_send (const iovec iov[], int n) |
virtual size_t | max_message_size () const |
Private Attributes | |
MulticastDataLink * | link_ |
Definition at line 23 of file MulticastSendStrategy.h.
OpenDDS::DCPS::MulticastSendStrategy::MulticastSendStrategy | ( | MulticastDataLink * | link | ) |
Definition at line 18 of file MulticastSendStrategy.cpp.
References defined(), if(), and OpenDDS::DCPS::TransportSendStrategy::link_released().
00019 : TransportSendStrategy(0, link->impl(), 00020 0, // synch_resource 00021 link->transport_priority(), 00022 make_rch<NullSynchStrategy>()), 00023 link_(link) 00024 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) 00025 , async_init_(false) 00026 #endif 00027 { 00028 // Multicast will send a SYN (TRANSPORT_CONTROL) before any reservations 00029 // are made on the DataLink, if the link is "release" it will be dropped. 00030 this->link_released(false); 00031 }
Definition at line 66 of file MulticastSendStrategy.cpp.
References OpenDDS::DCPS::MulticastDataLink::config(), ACE_Message_Block::cont(), ACE_IPC_SAP::get_handle(), OpenDDS::DCPS::MulticastDataLink::get_proactor(), OpenDDS::DCPS::MulticastInst::group_address_, iovec::iov_len, link_, ACE_Message_Block::release(), OpenDDS::DCPS::MulticastDataLink::socket(), and ACE_Message_Block::wr_ptr().
Referenced by send_bytes_i().
00067 { 00068 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) 00069 if (!async_init_) { 00070 if (-1 == async_writer_.open(*this, link_->socket().get_handle(), 0 /*completion_key*/, 00071 link_->get_proactor())) { 00072 return -1; 00073 } 00074 async_init_ = true; 00075 } 00076 00077 ACE_Message_Block* mb = 0; 00078 size_t total_length = 0; 00079 00080 for (int i = n - 1; i >= 0; --i) { 00081 ACE_Message_Block* next = 00082 new ACE_Message_Block(static_cast<const char*>(iov[i].iov_base), 00083 iov[i].iov_len); 00084 next->wr_ptr(iov[i].iov_len); 00085 total_length += iov[i].iov_len; 00086 next->cont(mb); 00087 mb = next; 00088 } 00089 00090 size_t bytes_sent = 0; 00091 ssize_t result = async_writer_.send(mb, bytes_sent, 0 /*flags*/, 00092 this->link_->config().group_address_); 00093 00094 if (result < 0) { 00095 if (mb) mb->release(); 00096 return result; 00097 } 00098 00099 // framework needs to think we sent the entire datagram 00100 return total_length; 00101 #else 00102 ACE_UNUSED_ARG(iov); 00103 ACE_UNUSED_ARG(n); 00104 return -1; 00105 #endif 00106 }
virtual size_t OpenDDS::DCPS::MulticastSendStrategy::max_message_size | ( | void | ) | const [inline, protected, virtual] |
The maximum size of a message allowed by the this TransportImpl, or 0 if there is no such limit. This is expected to be a constant, for example UDP/IPv4 can send messages of up to 65466 bytes. The transport framework will use the returned value (if > 0) to fragment larger messages. This fragmentation and reassembly will be transparent to the user.
Reimplemented from OpenDDS::DCPS::TransportSendStrategy.
Definition at line 42 of file MulticastSendStrategy.h.
00043 { 00044 return UDP_MAX_MESSAGE_SIZE; 00045 }
void OpenDDS::DCPS::MulticastSendStrategy::prepare_header_i | ( | ) | [protected, virtual] |
Specific implementation processing of prepared packet header.
Reimplemented from OpenDDS::DCPS::TransportSendStrategy.
Definition at line 34 of file MulticastSendStrategy.cpp.
References OpenDDS::DCPS::TransportSendStrategy::header_, link_, OpenDDS::DCPS::MulticastDataLink::local_peer(), and OpenDDS::DCPS::TransportHeader::source_.
00035 { 00036 // Tag outgoing packets with our peer ID: 00037 this->header_.source_ = this->link_->local_peer(); 00038 }
ssize_t OpenDDS::DCPS::MulticastSendStrategy::send_bytes_i | ( | const iovec | iov[], | |
int | n | |||
) | [protected, virtual] |
Implements OpenDDS::DCPS::TransportSendStrategy.
Definition at line 41 of file MulticastSendStrategy.cpp.
References async_send(), OpenDDS::DCPS::MulticastInst::async_send(), OpenDDS::DCPS::MulticastDataLink::config(), link_, and sync_send().
00042 { 00043 return (this->link_->config().async_send() ? async_send(iov, n) : sync_send(iov, n)); 00044 }
void OpenDDS::DCPS::MulticastSendStrategy::stop_i | ( | ) | [virtual] |
Let the subclass stop.
Implements OpenDDS::DCPS::TransportSendStrategy.
Definition at line 109 of file MulticastSendStrategy.cpp.
Definition at line 47 of file MulticastSendStrategy.cpp.
References link_, ACE_SOCK_Dgram_Mcast::send(), OpenDDS::DCPS::MulticastDataLink::socket(), and socket().
Referenced by send_bytes_i().
00048 { 00049 ACE_SOCK_Dgram_Mcast& socket = this->link_->socket(); 00050 00051 const ssize_t result = socket.send(iov, n); 00052 00053 if (result == -1 && errno == ENOBUFS) { 00054 // Make the framework think this was a successful send to avoid 00055 // putting the send strategy in suspended mode. If reliability 00056 // is enabled, the data may be resent later in response to a NAK. 00057 ssize_t b = 0; 00058 for (int i = 0; i < n; ++i) b += iov[i].iov_len; 00059 return b; 00060 } 00061 00062 return result; 00063 }
Definition at line 53 of file MulticastSendStrategy.h.
Referenced by async_send(), prepare_header_i(), send_bytes_i(), and sync_send().