#include <MulticastSendStrategy.h>
Inheritance diagram for OpenDDS::DCPS::MulticastSendStrategy:
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 21 of file MulticastSendStrategy.h.
OpenDDS::DCPS::MulticastSendStrategy::MulticastSendStrategy | ( | MulticastDataLink * | link | ) | [explicit] |
Definition at line 16 of file MulticastSendStrategy.cpp.
References OpenDDS::DCPS::TransportSendStrategy::link_released().
00017 : TransportSendStrategy(0, TransportInst_rch(link->config(), false), 00018 0, // synch_resource 00019 link->transport_priority(), 00020 new NullSynchStrategy), 00021 link_(link) 00022 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) 00023 , async_init_(false) 00024 #endif 00025 { 00026 // Multicast will send a SYN (TRANSPORT_CONTROL) before any reservations 00027 // are made on the DataLink, if the link is "release" it will be dropped. 00028 this->link_released(false); 00029 }
ssize_t OpenDDS::DCPS::MulticastSendStrategy::async_send | ( | const iovec | iov[], | |
int | n | |||
) | [protected] |
Definition at line 64 of file MulticastSendStrategy.cpp.
References OpenDDS::DCPS::MulticastDataLink::get_proactor(), link_, and OpenDDS::DCPS::MulticastDataLink::socket().
Referenced by send_bytes_i().
00065 { 00066 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) 00067 if (!async_init_) { 00068 if (-1 == async_writer_.open(*this, link_->socket().get_handle(), 0 /*completion_key*/, 00069 link_->get_proactor())) { 00070 return -1; 00071 } 00072 async_init_ = true; 00073 } 00074 00075 ACE_Message_Block* mb = 0; 00076 size_t total_length = 0; 00077 00078 for (int i = n - 1; i >= 0; --i) { 00079 ACE_Message_Block* next = 00080 new ACE_Message_Block(static_cast<const char*>(iov[i].iov_base), 00081 iov[i].iov_len); 00082 next->wr_ptr(iov[i].iov_len); 00083 total_length += iov[i].iov_len; 00084 next->cont(mb); 00085 mb = next; 00086 } 00087 00088 size_t bytes_sent = 0; 00089 ssize_t result = async_writer_.send(mb, bytes_sent, 0 /*flags*/, 00090 this->link_->config()->group_address_); 00091 00092 if (result < 0) { 00093 mb->release(); 00094 return result; 00095 } 00096 00097 // framework needs to think we sent the entire datagram 00098 return total_length; 00099 #else 00100 ACE_UNUSED_ARG(iov); 00101 ACE_UNUSED_ARG(n); 00102 return -1; 00103 #endif 00104 }
virtual size_t OpenDDS::DCPS::MulticastSendStrategy::max_message_size | ( | ) | 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 40 of file MulticastSendStrategy.h.
00041 { 00042 return UDP_MAX_MESSAGE_SIZE; 00043 }
void OpenDDS::DCPS::MulticastSendStrategy::prepare_header_i | ( | ) | [protected, virtual] |
Specific implementation processing of prepared packet header.
Reimplemented from OpenDDS::DCPS::TransportSendStrategy.
Definition at line 32 of file MulticastSendStrategy.cpp.
References OpenDDS::DCPS::TransportSendStrategy::header_, link_, OpenDDS::DCPS::MulticastDataLink::local_peer(), and OpenDDS::DCPS::TransportHeader::source_.
00033 { 00034 // Tag outgoing packets with our peer ID: 00035 this->header_.source_ = this->link_->local_peer(); 00036 }
ssize_t OpenDDS::DCPS::MulticastSendStrategy::send_bytes_i | ( | const iovec | iov[], | |
int | n | |||
) | [protected, virtual] |
Implements OpenDDS::DCPS::TransportSendStrategy.
Definition at line 39 of file MulticastSendStrategy.cpp.
References async_send(), and sync_send().
00040 { 00041 return (this->link_->config()->async_send() ? async_send(iov, n) : sync_send(iov, n)); 00042 }
void OpenDDS::DCPS::MulticastSendStrategy::stop_i | ( | ) | [virtual] |
Let the subclass stop.
Implements OpenDDS::DCPS::TransportSendStrategy.
Definition at line 107 of file MulticastSendStrategy.cpp.
00108 { 00109 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) 00110 if (async_init_) { 00111 async_writer_.cancel(); 00112 } 00113 #endif 00114 }
ssize_t OpenDDS::DCPS::MulticastSendStrategy::sync_send | ( | const iovec | iov[], | |
int | n | |||
) | [protected] |
Definition at line 45 of file MulticastSendStrategy.cpp.
References link_, and OpenDDS::DCPS::MulticastDataLink::socket().
Referenced by send_bytes_i().
00046 { 00047 ACE_SOCK_Dgram_Mcast& socket = this->link_->socket(); 00048 00049 const ssize_t result = socket.send(iov, n); 00050 00051 if (result == -1 && errno == ENOBUFS) { 00052 // Make the framework think this was a successful send to avoid 00053 // putting the send strategy in suspended mode. If reliability 00054 // is enabled, the data may be resent later in response to a NAK. 00055 ssize_t b = 0; 00056 for (int i = 0; i < n; ++i) b += iov[i].iov_len; 00057 return b; 00058 } 00059 00060 return result; 00061 }
Definition at line 51 of file MulticastSendStrategy.h.
Referenced by async_send(), prepare_header_i(), and sync_send().