Defines the member functions for the ACE QoS enabled socket wrapper for UDP/IP multicast. More...
#include <SOCK_Dgram_Mcast_QoS.h>


Public Member Functions | |
| ACE_SOCK_Dgram_Mcast_QoS (options opts=DEFOPTS) | |
| Ctor, has same defaults as ACE_SOCK_Dgram_Mcast. | |
| ~ACE_SOCK_Dgram_Mcast_QoS (void) | |
| Default dtor. | |
| int | subscribe (const ACE_INET_Addr &mcast_addr, const ACE_QoS_Params &qos_params, int reuse_addr=1, const ACE_TCHAR *net_if=0, int protocol_family=PF_INET, int protocol=0, ACE_Protocol_Info *protocolinfo=0, ACE_SOCK_GROUP g=0, u_long flags=0, ACE_QoS_Session *qos_session=0) |
| ssize_t | send (const iovec buffers[], int buffer_count, size_t &number_of_bytes_sent, int flags, const ACE_Addr &addr, ACE_OVERLAPPED *overlapped, ACE_OVERLAPPED_COMPLETION_FUNC func) const |
| ssize_t | send (const void *buf, size_t n, const ACE_Addr &addr, int flags, ACE_OVERLAPPED *overlapped, ACE_OVERLAPPED_COMPLETION_FUNC func) const |
| Send an n byte buf to the datagram socket (uses <WSASentTo>). | |
| ACE_QoS_Manager | qos_manager (void) |
| Returns the QoS manager for this socket. | |
| int | open (const ACE_INET_Addr &addr, const ACE_QoS_Params &qos_params, int protocol_family=PF_INET, int protocol=0, ACE_Protocol_Info *protocolinfo=0, ACE_SOCK_GROUP g=0, u_long flags=0, int reuse_addr=0) |
Public Attributes | |
| ACE_ALLOC_HOOK_DECLARE | |
| Declare the dynamic allocation hooks. | |
Private Member Functions | |
| int | subscribe_ifs (const ACE_INET_Addr &mcast_addr, const ACE_QoS_Params &qos_params, const ACE_TCHAR *net_if, int protocol_family, int protocol, int reuse_addr, ACE_Protocol_Info *protocolinfo) |
| Subscribe to the multicast interface using QoS-enabled semantics. | |
Private Attributes | |
| ACE_QoS_Manager | qos_manager_ |
| Manages the QoS sessions that this socket subscribes to. | |
Defines the member functions for the ACE QoS enabled socket wrapper for UDP/IP multicast.
Definition at line 33 of file SOCK_Dgram_Mcast_QoS.h.
| ACE_SOCK_Dgram_Mcast_QoS::ACE_SOCK_Dgram_Mcast_QoS | ( | options | opts = DEFOPTS |
) |
Ctor, has same defaults as ACE_SOCK_Dgram_Mcast.
| ACE_SOCK_Dgram_Mcast_QoS::~ACE_SOCK_Dgram_Mcast_QoS | ( | void | ) |
| int ACE_SOCK_Dgram_Mcast_QoS::open | ( | const ACE_INET_Addr & | addr, | |
| const ACE_QoS_Params & | qos_params, | |||
| int | protocol_family = PF_INET, |
|||
| int | protocol = 0, |
|||
| ACE_Protocol_Info * | protocolinfo = 0, |
|||
| ACE_SOCK_GROUP | g = 0, |
|||
| u_long | flags = 0, |
|||
| int | reuse_addr = 0 | |||
| ) |
Definition at line 39 of file SOCK_Dgram_Mcast_QoS.cpp.
{
ACE_TRACE ("ACE_SOCK_Dgram_Mcast_QoS::open");
ACE_UNUSED_ARG (qos_params);
// Only perform the <open> initialization if we haven't been opened
// earlier.
if (this->get_handle () != ACE_INVALID_HANDLE)
return 0;
ACE_DEBUG ((LM_DEBUG,
"Get Handle Returns Invalid Handle\n"));
if (ACE_SOCK::open (SOCK_DGRAM,
protocol_family,
protocol,
protocolinfo,
g,
flags,
reuse_addr) == -1)
return -1;
return this->open_i (addr, 0, reuse_addr);
}
| ACE_QoS_Manager ACE_SOCK_Dgram_Mcast_QoS::qos_manager | ( | void | ) |
Returns the QoS manager for this socket.
Definition at line 52 of file SOCK_Dgram_Mcast_QoS.inl.
{
return this->qos_manager_;
}
| ssize_t ACE_SOCK_Dgram_Mcast_QoS::send | ( | const iovec | buffers[], | |
| int | buffer_count, | |||
| size_t & | number_of_bytes_sent, | |||
| int | flags, | |||
| const ACE_Addr & | addr, | |||
| ACE_OVERLAPPED * | overlapped, | |||
| ACE_OVERLAPPED_COMPLETION_FUNC | func | |||
| ) | const |
Send <buffer_count> worth of buffers to addr using overlapped I/O (uses <WSASentTo>). Returns 0 on success.
Reimplemented from ACE_SOCK_Dgram.
Definition at line 13 of file SOCK_Dgram_Mcast_QoS.inl.
{
ACE_TRACE ("ACE_SOCK_Dgram_Mcast_QoS::send");
return ACE_SOCK_Dgram::send (buffers,
buffer_count,
number_of_bytes_sent,
flags,
addr,
overlapped,
func);
}
| ssize_t ACE_SOCK_Dgram_Mcast_QoS::send | ( | const void * | buf, | |
| size_t | n, | |||
| const ACE_Addr & | addr, | |||
| int | flags, | |||
| ACE_OVERLAPPED * | overlapped, | |||
| ACE_OVERLAPPED_COMPLETION_FUNC | func | |||
| ) | const |
Send an n byte buf to the datagram socket (uses <WSASentTo>).
Reimplemented from ACE_SOCK_Dgram.
Definition at line 34 of file SOCK_Dgram_Mcast_QoS.inl.
{
ACE_TRACE ("ACE_SOCK_Dgram_Mcast_QoS::send");
return ACE_SOCK_Dgram::send (buf,
n,
addr,
flags,
overlapped,
func);
}
| int ACE_SOCK_Dgram_Mcast_QoS::subscribe | ( | const ACE_INET_Addr & | mcast_addr, | |
| const ACE_QoS_Params & | qos_params, | |||
| int | reuse_addr = 1, |
|||
| const ACE_TCHAR * | net_if = 0, |
|||
| int | protocol_family = PF_INET, |
|||
| int | protocol = 0, |
|||
| ACE_Protocol_Info * | protocolinfo = 0, |
|||
| ACE_SOCK_GROUP | g = 0, |
|||
| u_long | flags = 0, |
|||
| ACE_QoS_Session * | qos_session = 0 | |||
| ) |
This is a QoS-enabled method for joining a multicast group, which passes <qos_params> via <ACE_OS::join_leaf>. The network interface device driver is instructed to accept datagrams with <mcast_addr> multicast addresses. If the socket has already been opened, <subscribe> closes the socket and opens a new socket bound to the <mcast_addr>. The session object specifies the QoS session that the socket wants to subscribe to. A socket may subscribe to multiple QoS sessions by calling this method multiple times with different session objects.
The <net_if> interface is hardware specific, e.g., use "netstat -i" to find whether your interface is, such as "le0" or something else. If net_if == 0, <subscribe> uses the default mcast interface. Returns: -1 if the call fails.
Note that some platforms, such as pSoS, support only number, not names, for network interfaces. For these platforms, just give these numbers in alphanumeric form and <subscribe> will convert them into numbers via <ACE_OS::atoi>.
Definition at line 178 of file SOCK_Dgram_Mcast_QoS.cpp.
{
ACE_TRACE ("ACE_SOCK_Dgram_Mcast_QoS::subscribe");
if (this->open (mcast_addr,
qos_params,
protocol_family,
protocol,
protocolinfo,
g,
flags,
reuse_addr) == -1)
return -1;
// The following method call only applies to Win32 currently.
int result = this->subscribe_ifs (mcast_addr,
qos_params,
net_if,
protocol_family,
protocol,
reuse_addr,
protocolinfo);
// Check for the "short-circuit" return value of 1 (for NT).
if (result != 0)
return result;
// Tell network device driver to read datagrams with a
// <mcast_request_if_> IP interface.
else
{
// Check if the mcast_addr passed into this method is the
// same as the QoS session address.
if (qos_session != 0 && mcast_addr == qos_session->dest_addr ())
{
// Subscribe to the QoS session.
if (this->qos_manager_.join_qos_session (qos_session) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("Unable to join QoS Session\n")),
-1);
}
else
{
if (this->close () != 0)
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("Unable to close socket\n")));
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("Dest Addr in the QoS Session does")
ACE_TEXT (" not match the address passed into")
ACE_TEXT (" subscribe\n")),
-1);
}
ip_mreq ret_mreq;
this->make_multicast_ifaddr (&ret_mreq, mcast_addr, net_if);
// XX This is windows stuff only. fredk
if (ACE_OS::join_leaf (this->get_handle (),
reinterpret_cast<const sockaddr *> (&ret_mreq.IMR_MULTIADDR.s_addr),
sizeof ret_mreq.IMR_MULTIADDR.s_addr,
qos_params) == ACE_INVALID_HANDLE
&& errno != ENOTSUP)
return -1;
else
if (qos_params.socket_qos () != 0 && qos_session != 0)
qos_session->qos (*(qos_params.socket_qos ()));
return 0;
}
}
| int ACE_SOCK_Dgram_Mcast_QoS::subscribe_ifs | ( | const ACE_INET_Addr & | mcast_addr, | |
| const ACE_QoS_Params & | qos_params, | |||
| const ACE_TCHAR * | net_if, | |||
| int | protocol_family, | |||
| int | protocol, | |||
| int | reuse_addr, | |||
| ACE_Protocol_Info * | protocolinfo | |||
| ) | [private] |
Subscribe to the multicast interface using QoS-enabled semantics.
Definition at line 74 of file SOCK_Dgram_Mcast_QoS.cpp.
{
ACE_TRACE ("ACE_SOCK_Dgram_Mcast_QoS::subscribe_ifs");
#if defined (ACE_WIN32)
// Windows NT's winsock has trouble with multicast subscribes in the
// presence of multiple network interfaces when the IP address is
// given as INADDR_ANY. It will pick the first interface and only
// accept mcast there. So, to work around this, cycle through all
// of the interfaces known and subscribe to all the non-loopback
// ones.
//
// Note that this only needs to be done on NT, but there's no way to
// tell at this point if the code will be running on NT - only if it
// is compiled for NT-only or for NT/95, and that doesn't really
// help us. It doesn't hurt to do this on Win95, it's just a little
// slower than it normally would be.
//
// NOTE - <ACE_Sock_Connect::get_ip_interfaces> doesn't always get all
// of the interfaces. In particular, it may not get a PPP interface. This
// is a limitation of the way <ACE_Sock_Connect::get_ip_interfaces> works
// with MSVC. The reliable way of getting the interface list is
// available only with MSVC 5.
if (net_if == 0)
{
ACE_INET_Addr *if_addrs = 0;
size_t if_cnt;
if (ACE::get_ip_interfaces (if_cnt, if_addrs) != 0)
return -1;
size_t nr_subscribed = 0;
if (if_cnt < 2)
{
if (this->subscribe (mcast_addr,
qos_params,
reuse_addr,
ACE_TEXT ("0.0.0.0"),
protocol_family,
protocol,
protocolinfo) == 0)
++nr_subscribed;
}
else
// Iterate through all the interfaces, figure out which ones
// offer multicast service, and subscribe to them.
while (if_cnt > 0)
{
--if_cnt;
// Convert to 0-based for indexing, next loop check.
if (if_addrs[if_cnt].is_loopback())
continue;
if (this->subscribe (mcast_addr,
qos_params,
reuse_addr,
ACE_TEXT_CHAR_TO_TCHAR
(if_addrs[if_cnt].get_host_addr()),
protocol_family,
protocol,
protocolinfo) == 0)
++nr_subscribed;
}
delete [] if_addrs;
if (nr_subscribed == 0)
{
errno = ENODEV;
return -1;
}
else
// 1 indicates a "short-circuit" return. This handles the
// rather bizarre semantics of checking all the interfaces on
// NT.
return 1;
}
#else
ACE_UNUSED_ARG (mcast_addr);
ACE_UNUSED_ARG (qos_params);
ACE_UNUSED_ARG (protocol_family);
ACE_UNUSED_ARG (protocol);
ACE_UNUSED_ARG (reuse_addr);
ACE_UNUSED_ARG (protocolinfo);
#endif /* ACE_WIN32 */
// Otherwise, do it like everyone else...
// Create multicast request.
if (this->make_multicast_ifaddr (0,
mcast_addr,
net_if) == -1)
return -1;
else
return 0;
}
Declare the dynamic allocation hooks.
Reimplemented from ACE_SOCK_Dgram_Mcast.
Definition at line 106 of file SOCK_Dgram_Mcast_QoS.h.
Manages the QoS sessions that this socket subscribes to.
Definition at line 131 of file SOCK_Dgram_Mcast_QoS.h.
1.7.0