ACE
6.1.6
|
Defines the ACE socket wrapper for UDP/IP multicast. More...
#include <SOCK_Dgram_Mcast.h>
Public Types | |
enum | options { OPT_BINDADDR_NO = 0, OPT_BINDADDR_YES = 1, DEFOPT_BINDADDR = OPT_BINDADDR_NO, OPT_NULLIFACE_ONE = 0, OPT_NULLIFACE_ALL = 2, DEFOPT_NULLIFACE = OPT_NULLIFACE_ALL, DEFOPTS = DEFOPT_BINDADDR | DEFOPT_NULLIFACE } |
Option parameters. More... | |
![]() | |
typedef ACE_INET_Addr | PEER_ADDR |
Public Member Functions | |
ACE_SOCK_Dgram_Mcast (options opts=DEFOPTS) | |
~ACE_SOCK_Dgram_Mcast (void) | |
int | open (const ACE_INET_Addr &mcast_addr, const ACE_TCHAR *net_if=0, int reuse_addr=1) |
int | join (const ACE_INET_Addr &mcast_addr, int reuse_addr=1, const ACE_TCHAR *net_if=0) |
int | leave (const ACE_INET_Addr &mcast_addr, const ACE_TCHAR *net_if=0) |
ssize_t | send (const void *buf, size_t n, int flags=0) const |
ssize_t | send (const iovec iov[], int n, int flags=0) const |
int | set_option (int option, char optval) |
Set a socket option. | |
void | dump (void) const |
Dump the state of an object. | |
void | opts (int opts) |
int | opts () const |
Read acessor for the constructor options (. | |
![]() | |
ACE_SOCK_Dgram (void) | |
Default constructor. | |
ACE_SOCK_Dgram (const ACE_Addr &local, int protocol_family=ACE_PROTOCOL_FAMILY_INET, int protocol=0, int reuse_addr=0) | |
ACE_SOCK_Dgram (const ACE_Addr &local, int protocol_family, int protocol, ACE_Protocol_Info *protocolinfo, ACE_SOCK_GROUP g=0, u_long flags=0, int reuse_addr=0) | |
int | open (const ACE_Addr &local, int protocol_family=ACE_PROTOCOL_FAMILY_INET, int protocol=0, int reuse_addr=0) |
int | open (const ACE_Addr &local, int protocol_family, int protocol, ACE_Protocol_Info *protocolinfo, ACE_SOCK_GROUP g=0, u_long flags=0, int reuse_addr=0) |
~ACE_SOCK_Dgram (void) | |
Default dtor. | |
ssize_t | send (const void *buf, size_t n, const ACE_Addr &addr, int flags=0) const |
Send an n byte buf to the datagram socket (uses <sendto(3)>). | |
ssize_t | recv (void *buf, size_t n, ACE_Addr &addr, int flags=0) const |
ssize_t | recv (iovec *io_vec, ACE_Addr &addr, int flags=0, const ACE_Time_Value *timeout=0) const |
ssize_t | send (const iovec iov[], int n, const ACE_Addr &addr, int flags=0) const |
ssize_t | recv (iovec iov[], int n, ACE_Addr &addr, int flags=0) const |
ssize_t | recv (void *buf, size_t n, ACE_Addr &addr, int flags, const ACE_Time_Value *timeout) const |
ssize_t | send (const void *buf, size_t n, const ACE_Addr &addr, int flags, const ACE_Time_Value *timeout) const |
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 | recv (iovec buffers[], int buffer_count, size_t &number_of_bytes_recvd, int &flags, 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 <WSASendTo>). | |
ssize_t | recv (void *buf, size_t n, ACE_Addr &addr, int flags, ACE_OVERLAPPED *overlapped, ACE_OVERLAPPED_COMPLETION_FUNC func) const |
int | set_nic (const ACE_TCHAR *net_if, int addr_family=AF_UNSPEC) |
Set NIC to use as multicast interface. | |
![]() | |
int | set_option (int level, int option, void *optval, int optlen) const |
Wrapper around the setsockopt system call. | |
int | get_option (int level, int option, void *optval, int *optlen) const |
Wrapper around the getsockopt system call. | |
int | close (void) |
int | get_local_addr (ACE_Addr &) const |
int | open (int type, int protocol_family, int protocol, int reuse_addr) |
Wrapper around the BSD-style socket system call (no QoS). | |
int | open (int type, int protocol_family, int protocol, ACE_Protocol_Info *protocolinfo, ACE_SOCK_GROUP g, u_long flags, int reuse_addr) |
Wrapper around the QoS-enabled WSASocket function. | |
![]() | |
int | control (int cmd, void *) const |
Interface for <ioctl>. | |
int | enable (int value) const |
int | disable (int value) const |
ACE_HANDLE | get_handle (void) const |
Get the underlying handle. | |
void | set_handle (ACE_HANDLE handle) |
Set the underlying handle. |
Public Attributes | |
ACE_ALLOC_HOOK_DECLARE | |
Declare the dynamic allocation hooks. | |
![]() | |
![]() | |
![]() |
Protected Member Functions | |
int | open_i (const ACE_INET_Addr &mcast_addr, const ACE_TCHAR *net_if=0, int reuse_addr=1) |
int | clear_subs_list (void) |
Empty the dynamic subscription list. | |
![]() | |
int | shared_open (const ACE_Addr &local, int protocol_family) |
Open is shared by this and by <LSOCK_Dgram>. | |
int | make_multicast_ifaddr (ip_mreq *mreq, const ACE_INET_Addr &mcast_addr, const ACE_TCHAR *net_if) |
int | make_multicast_ifaddr6 (ipv6_mreq *mreq, const ACE_INET_Addr &mcast_addr, const ACE_TCHAR *net_if) |
![]() | |
ACE_SOCK (int type, int protocol_family, int protocol=0, int reuse_addr=0) | |
ACE_SOCK (int type, int protocol_family, int protocol, ACE_Protocol_Info *protocolinfo, ACE_SOCK_GROUP g, u_long flags, int reuse_addr) | |
ACE_SOCK (void) | |
~ACE_SOCK (void) | |
Protected destructor. | |
![]() | |
ACE_IPC_SAP (void) | |
Default constructor. | |
~ACE_IPC_SAP (void) | |
Protected destructor. |
Private Member Functions | |
int | subscribe_ifs (const ACE_INET_Addr &mcast_addr, const ACE_TCHAR *net_if, int reuse_addr) |
int | subscribe_i (const ACE_INET_Addr &mcast_addr, int reuse_addr=1, const ACE_TCHAR *net_if=0) |
int | unsubscribe_ifs (const ACE_INET_Addr &mcast_addr, const ACE_TCHAR *net_if=0) |
Unsubscribe from a multicast address on one or more network interface(s). | |
int | unsubscribe_i (const ACE_INET_Addr &mcast_addr, const ACE_TCHAR *net_if=0) |
Private Attributes | |
int | opts_ |
Per-instance options.. | |
ACE_INET_Addr | send_addr_ |
Multicast address to which local send() methods send datagrams. | |
ACE_TCHAR * | send_net_if_ |
Network interface to which all send() methods send multicast datagrams. |
Defines the ACE socket wrapper for UDP/IP multicast.
Supports multiple simultaneous subscriptions, unsubscription from one or all subscriptions, and independent send/recv address and interface specifications. Constructor arguments determine per-instance optional functionality.
Note that multicast semantics and implementation details are very environment-specific; this class is just a wrapper around the underlying implementation and does not try to normalize the concept of multicast communications.
Usage Notes:
Interface specification notes (for subscribe() and unsubscribe()):
OPT_NULLIFACE_ALL
and OPT_NULLIFACE_ONE
options determine whether only the system default interface (if OPT_NULLIFACE_ONE
is set) or all interfaces (if OPT_NULLIFACE_ALL
is set) is affected. Specifying all interfaces functions correctly only on:Option parameters.
These control per-instance optional functionality. They are set via an optional constructor argument.
ACE_SOCK_Dgram_Mcast::ACE_SOCK_Dgram_Mcast | ( | ACE_SOCK_Dgram_Mcast::options | opts = DEFOPTS | ) |
ACE_SOCK_Dgram_Mcast::~ACE_SOCK_Dgram_Mcast | ( | void | ) |
Release all resources and implicitly or explicitly unsubscribe from all currently subscribed groups. The OPT_DTORUNSUB_YES_ option defines whether an explicit unsubscribe() is done by the destructor. If not, most systems will automatically unsubscribe upon the close of the socket.
|
protected |
Empty the dynamic subscription list.
void ACE_SOCK_Dgram_Mcast::dump | ( | void | ) | const |
Dump the state of an object.
Logs the setting of all options, the bound address, the send address and interface, and the list of current subscriptions.
Reimplemented from ACE_SOCK_Dgram.
int ACE_SOCK_Dgram_Mcast::join | ( | const ACE_INET_Addr & | mcast_addr, |
int | reuse_addr = 1 , |
||
const ACE_TCHAR * | net_if = 0 |
||
) |
Join a multicast group on a given interface (or all interfaces, if supported). The given group is joined on the specified interface. If option OPT_NULLIFACE_ALL is used and net_if is = 0, the group is joined on all multicast capable interfaces (IFF supported). Multiple subscriptions to various address and interface combinations are supported and tracked. If this is the first invocation of subscribe(), and open() was not previously invoked, open() will be invoked using mcast_addr for binding the socket and net_if as the interface for send().
Returns: -1 if the call fails. Failure can occur due to problems with the address, port#, and/or interface parameters or during the subscription attempt. Once bind() has been invoked (by the first open() or subscribe()), returns errno of ENXIO if the port# is not 0 and does not match the bound port#, or if OPT_BINDADDR_YES option is used and the address does not match the bound address. Returns errno of ENODEV if the addr/port#/interface parameters appeared valid, but no subscription(s) succeeded. An error is unconditionally returned if option OPT_NULLIFACE_ALL is used, net_if is NULL, and ACE_Sock_Connect::get_ip_interfaces() is not implemented in this environment.
Note that the optional reuse_addr parameter does not apply to subscriptions; it is only used if open() is implicitly invoked (see above).
Uses the mcast_addr to determine protocol_family, and protocol which we always pass as 0 anyway.
int ACE_SOCK_Dgram_Mcast::leave | ( | const ACE_INET_Addr & | mcast_addr, |
const ACE_TCHAR * | net_if = 0 |
||
) |
Leave a multicast group on a given interface (or all interfaces, if supported). The specified group/interface combination is unsubscribed. If option OPT_NULLIFACE_ALL is used and net_if is = 0, the group is unsubscribed from all interfaces (IFF supported).
Returns: -1 if the unsubscribe failed. Most environments will return -1 if there was no active subscription for this address/interface combination. An error is unconditionally returned if option OPT_NULLIFACE_ALL is used, net_if is = 0, and ACE_Sock_Connect::get_ip_interfaces() is not implemented in this environment (even if the subscribe() specifies a non- NULL net_if).
leave() replaces unsubscribe() and uses mcast_addr to determine protocol_family, and protocol which we always pass as 0 anyway.
int ACE_SOCK_Dgram_Mcast::open | ( | const ACE_INET_Addr & | mcast_addr, |
const ACE_TCHAR * | net_if = 0 , |
||
int | reuse_addr = 1 |
||
) |
Explicitly open/bind the socket and define the network interface and default multicast address used for sending messages.
This method is optional; if not explicitly invoked, it is invoked by the first join(), using the subscribed address/port number and network interface parameters.
mcast_addr | Defines the default send address/port number and, if the OPT_BINDADDR_YES option is used, the multicast address that is bound to this socket. The port number in mcast_addr may be 0, in which case a system-assigned (ephemeral) port number is used for sending and receiving. |
net_if | If net_if is not 0, it defines the network interface used for all sends by this instance, otherwise the system default interface is used. (The net_if parameter is ignored if this feature is not supported by the environment.) |
reuse_addr | If reuse_addr is not 0, the SO_REUSEADDR option and, if it is supported, the SO_REUSEPORT option are enabled. |
0 | on success |
-1 | if the call fails. Failure can occur due to problems with the address, port, and/or interface parameters or during system open() or socket option processing. |
|
protected |
Contains common open functionality so that inheriting classes can reuse it.
|
inline |
Override write acessor for the constructor options (
|
inline |
Read acessor for the constructor options (.
|
inline |
Send n bytes in buf, using the multicast address and network interface defined by the first open() or subscribe().
|
inline |
Send n iovecs, using the multicast address and network interface defined by the first open() or subscribe().
|
inline |
Set a socket option.
Set an IP option that takes a char as input, such as IP_MULTICAST_LOOP or IP_MULTICAST_TTL. This is just a more concise, nice interface to a subset of possible ACE_SOCK::set_option calls, but only works for IPPROTO_IP or IPPROTO_IPV6 level options.
Returns 0 on success, -1 on failure.
|
private |
Do subscription processing w/out updating the subscription list. (Layered method for <subscribe> processing).
|
private |
Subscribe to a multicast address on one or more network interface(s). (No QoS support.)
|
private |
Do unsubscription processing w/out udpating subscription list. (Layered method for <unsubscribe> processing).
|
private |
Unsubscribe from a multicast address on one or more network interface(s).
ACE_SOCK_Dgram_Mcast::ACE_ALLOC_HOOK_DECLARE |
Declare the dynamic allocation hooks.
Reimplemented from ACE_SOCK_Dgram.
|
private |
Per-instance options..
|
private |
Multicast address to which local send() methods send datagrams.
|
private |
Network interface to which all send() methods send multicast datagrams.