A type X meets the MulticastGroupSocketOption requirements if it satisfies the requirements of Destructible (C++ 2014 [destructible]), CopyConstructible (C++ 2014 [copyconstructible]), CopyAssignable (C++ 2014 [copyassignable]), and SettableSocketOption ([socket.reqmts.settablesocketoption]), as well as the additional requirements listed below.
In the table below, a denotes a (possibly const) value of type address, b and c denote (possibly const) values of type address_v4, d denotes a (possibly const) value of type address_v6, e denotes a (possibly const) value of type unsigned int, and u denotes an identifier.
expression | type | assertion/note pre/post-conditions |
X u(a); | Constructs a multicast group socket option to join the group with the specified version-independent address. | |
X u(b, c); | Constructs a multicast group socket option to join the specified IPv4 address on a specified network interface. | |
X u(d, e); | Constructs a multicast group socket option to join the specified IPv6 address on a specified network interface. |
In this document, types that satisfy the MulticastGroupSocketOption requirements are defined as follows.
class C{
public:
// constructors:
explicit C(const address& multicast_group) noexcept;
explicit C(const address_v4& multicast_group,
const address_v4& network_interface = address_v4::any()) noexcept;
explicit C(const address_v6& multicast_group,
unsigned int network_interface = 0) noexcept;
};
Extensible implementations provide the following member functions:
class C{ public: template<class Protocol> int level(const Protocol& p) const noexcept; template<class Protocol> int name(const Protocol& p) const noexcept; template<class Protocol> const void* data(const Protocol& p) const noexcept; template<class Protocol> size_t size(const Protocol& p) const noexcept; // remainder unchanged private: ip_mreq v4_value_; // exposition only ipv6_mreq v6_value_; // exposition only };
Let L and N identify the POSIX macros to be passed as the level and option_name arguments, respectively, to POSIX setsockopt and getsockopt.
explicit C(const address& multicast_group) noexcept;
Effects: If multicast_group.is_v6() is true, calls C(multicast_group.to_v6()); otherwise, calls C(multicast_group.to_v4()).
explicit C(const address_v4& multicast_group,
const address_v4& network_interface = address_v4::any()) noexcept;
Effects: For extensible implementations, v4_value_.imr_multiaddr is initialized to correspond to the address multicast_group, v4_value_.imr_interface is initialized to correspond to address network_interface, and v6_value_ is zero-initialized.
explicit C(const address_v6& multicast_group,
unsigned int network_interface = 0) noexcept;
Effects: For extensible implementations, v6_value_.ipv6mr_multiaddr is initialized to correspond to the address multicast_group, v6_value_.ipv6mr_interface is initialized to network_interface, and v4_value_ is zero-initialized.
template<class Protocol> int level(const Protocol& p) const noexcept;
Returns: L.
template<class Protocol> int name(const Protocol& p) const noexcept;
Returns: N.
template<class Protocol> const void* data(const Protocol& p) const noexcept;
Returns: addressof(v6_value_) if p.family() == AF_INET6, otherwise addressof(v4_value_).
template<class Protocol> size_t size(const Protocol& p) const noexcept;
Returns: sizeof(v6_value_) if p.family() == AF_INET6, otherwise sizeof(v4_value_).