The class udp encapsulates the types and flags necessary for UDP sockets.
namespace std { namespace experimental { namespace net { inline namespace v1 { namespace ip { class udp { public: // types: using endpoint = basic_endpoint<udp>; using resolver = basic_resolver<udp>; using socket = basic_datagram_socket<udp>; // static members: static constexpr udp v4() noexcept; static constexpr udp v6() noexcept; udp() = delete; }; // [internet.udp.comparisons], udp comparisons: constexpr bool operator==(const udp& a, const udp& b) noexcept; constexpr bool operator!=(const udp& a, const udp& b) noexcept; } // namespace ip } // inline namespace v1 } // namespace net } // namespace experimental } // namespace std
Extensible implementations provide the following member functions:
namespace std { namespace experimental { namespace net { inline namespace v1 { namespace ip { class udp { public: constexpr int family() const noexcept; constexpr int type() const noexcept; constexpr int protocol() const noexcept; // remainder unchanged }; } // namespace ip } // inline namespace v1 } // namespace net } // namespace experimental } // namespace std
The return values for these member functions are listed in Table [tab:internet.udp.requirements].
value | family() | type() | protocol() |
udp::v4() | AF_INET | SOCK_DGRAM | IPPROTO_UDP |
udp::v6() | AF_INET6 | SOCK_DGRAM | IPPROTO_UDP |
[ Note: The constants AF_INET, AF_INET6 and SOCK_DGRAM are defined in the POSIX <sys/socket.h> header. The constant IPPROTO_UDP is defined in the POSIX <netinet/in.h> header. — end note ]
constexpr bool operator==(const udp& a, const udp& b) noexcept;
Returns: A boolean indicating whether two objects of class udp are equal, such that the expression udp::v4() == udp::v4() is true, the expression udp::v6() == udp::v6() is true, and the expression udp::v4() == udp::v6() is false.
constexpr bool operator!=(const udp& a, const udp& b) noexcept;
Returns: !(a == b).