The class tcp encapsulates the types and flags necessary for TCP sockets.
namespace std { namespace experimental { namespace net { inline namespace v1 { namespace ip { class tcp { public: // types: using endpoint = basic_endpoint<tcp>; using resolver = basic_resolver<tcp>; using socket = basic_stream_socket<tcp>; using acceptor = basic_socket_acceptor<tcp>; using iostream = basic_socket_iostream<tcp>; class no_delay; // static members: static constexpr tcp v4() noexcept; static constexpr tcp v6() noexcept; tcp() = delete; }; // [internet.tcp.comparisons], tcp comparisons: constexpr bool operator==(const tcp& a, const tcp& b) noexcept; constexpr bool operator!=(const tcp& a, const tcp& 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 tcp { 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.tcp.requirements].
value | family() | type() | protocol() |
tcp::v4() | AF_INET | SOCK_STREAM | IPPROTO_TCP |
tcp::v6() | AF_INET6 | SOCK_STREAM | IPPROTO_TCP |
[ Note: The constants AF_INET, AF_INET6 and SOCK_STREAM are defined in the POSIX <sys/socket.h> header. The constant IPPROTO_TCP is defined in the POSIX <netinet/in.h> header. — end note ]
constexpr bool operator==(const tcp& a, const tcp& b) noexcept;
Returns: A boolean indicating whether two objects of class tcp are equal, such that the expression tcp::v4() == tcp::v4() is true, the expression tcp::v6() == tcp::v6() is true, and the expression tcp::v4() == tcp::v6() is false.
constexpr bool operator!=(const tcp& a, const tcp& b) noexcept;
Returns: !(a == b).