21 Internet protocol [internet]

21.21 Internet socket options [internet.socket.opt]

In Table [tab:internet.socket.opt.requirements], let C denote a socket option class; let L identify the POSIX macro to be passed as the level argument to POSIX setsockopt and getsockopt; let N identify the POSIX macro to be passed as the option_name argument to POSIX setsockopt and getsockopt; let T identify the type of the value whose address will be passed as the option_value argument to POSIX setsockopt and getsockopt; let p denote a (possibly const) value of a type meeting the protocol ([socket.reqmts.protocol]) requirements, as passed to the socket option's level and name member functions; and let F be the value of p.family().

Table 40 — Internet socket options
CLNTRequirements,
definition or notes
ip::tcp::
no_delay
IPPROTO_TCP TCP_NODELAY int Satisfies the BooleanSocketOption ([socket.reqmts.opt.bool]) type requirements. Determines whether a TCP socket will avoid coalescing of small segments. [ Note: That is, setting this option disables the Nagle algorithm.  — end note ]
ip::v6_only IPPROTO_IPV6 IPV6_V6ONLY int Satisfies the BooleanSocketOption ([socket.reqmts.opt.bool]) type requirements. Determines whether a socket created for an IPv6 protocol is restricted to IPv6 communications only. Implementations are not required to support setting the v6_only option to false, and the initial value of the v6_only option for a socket is implementation-defined. [ Note: As not all operating systems support dual stack IP networking. Some operating systems that do provide dual stack support offer a configuration option to disable it or to set the initial value of the v6_only socket option.  — end note ]
ip::unicast:: hops IPPROTO_IPV6 if F == AF_INET6, otherwise IPPROTO_IP IPV6_UNICAST_HOPS if F == AF_INET6, otherwise IP_TTL int Satisfies the IntegerSocketOption ([socket.reqmts.opt.int]) type requirements. Specifies the default number of hops (also known as time-to-live or TTL) on outbound datagrams. The constructor and assignment operator for the ip::unicast::hops class throw out_of_range if the int argument is not in the range [0, 255].
ip::multicast:: join_group IPPROTO_IPV6 if F == AF_INET6, otherwise IPPROTO_IP IPV6_JOIN_GROUP if F == AF_INET6, otherwise IP_ADD_MEMBERSHIP ipv6_mreq if F == AF_INET6, otherwise ip_mreq Satisfies the MulticastGroupSocketOption ([internet.reqmts.opt.mcast]) type requirements. Requests that the socket join the specified multicast group.
ip::multicast:: leave_group IPPROTO_IPV6 if F == AF_INET6, otherwise IPPROTO_IP IPV6_LEAVE_GROUP if F == AF_INET6, otherwise IP_DROP_MEMBERSHIP ipv6_mreq if F == AF_INET6, otherwise ip_mreq Satisfies the MulticastGroupSocketOption ([internet.reqmts.opt.mcast]) type requirements. Requests that the socket leave the specified multicast group.
ip::multicast:: outbound_interface
([internet.multicast.outbound])
IPPROTO_IPV6 if F == AF_INET6, otherwise IPPROTO_IP IPV6_MULTICAST_IF if F == AF_INET6, otherwise IP_MULTICAST_IF unsigned int if F == AF_INET6, otherwise in_addr Specifies the network interface to use for outgoing multicast datagrams.
ip::multicast:: hops IPPROTO_IPV6 if F == AF_INET6, otherwise IPPROTO_IP IPV6_MULTICAST_HOPS if F == AF_INET6, otherwise IP_MULTICAST_TTL int Satisfies the IntegerSocketOption ([socket.reqmts.opt.int]) type requirements. Specifies the default number of hops (also known as time-to-live or TTL) on outbound datagrams. The constructor and assignment operator for the ip::multicast::hops class throw out_of_range if the int argument is not in the range [0, 255].
ip::multicast:: enable_loopback IPPROTO_IPV6 if F == AF_INET6, otherwise IPPROTO_IP IPV6_MULTICAST_LOOP if F == AF_INET6, otherwise IP_MULTICAST_LOOP int Satisfies the BooleanSocketOption ([socket.reqmts.opt.bool]) type requirements. Determines whether multicast datagrams are delivered back to the local application.

21.21.1 Class ip::multicast::outbound_interface [internet.multicast.outbound]

The outbound_interface class represents a socket option that specifies the network interface to use for outgoing multicast datagrams.

namespace std {
namespace experimental {
namespace net {
inline namespace v1 {
namespace ip {
namespace multicast {

  class outbound_interface
  {
  public:
    // constructors:
    explicit outbound_interface(const address_v4& network_interface) noexcept;
    explicit outbound_interface(unsigned int network_interface) noexcept;
  };

} // namespace multicast
} // namespace ip
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std

outbound_interface satisfies the requirements for Destructible (C++ 2014 [destructible]), CopyConstructible (C++ 2014 [copyconstructible]), CopyAssignable (C++ 2014 [copyassignable]), and SettableSocketOption ([socket.reqmts.settablesocketoption]).

Extensible implementations provide the following member functions:

namespace std {
namespace experimental {
namespace net {
inline namespace v1 {
namespace ip {
namespace multicast {

  class outbound_interface
  {
  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:
      in_addr v4_value_; // exposition only
      unsigned int v6_value_; // exposition only
  };

} // namespace multicast
} // namespace ip
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std

explicit outbound_interface(const address_v4& network_interface) noexcept;

Effects: For extensible implementations, v4_value_ is initialized to correspond to the IPv4 address network_interface, and v6_value_ is zero-initialized.

explicit outbound_interface(unsigned int network_interface) noexcept;

Effects: For extensible implementations, v6_value_ is initialized to network_interface, and v4_value_ is zero-initialized.

template<class Protocol> int level(const Protocol& p) const noexcept;

Returns: IPPROTO_IPV6 if p.family() == AF_INET6, otherwise IPPROTO_IP.

template<class Protocol> int name(const Protocol& p) const noexcept;

Returns: IPV6_MULTICAST_IF if p.family() == AF_INET6, otherwise IP_MULTICAST_IF.

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_).