1#ifndef UVW_TCP_INCLUDE_H
2#define UVW_TCP_INCLUDE_H
18enum class UVTCPFlags : std::underlying_type_t<uv_tcp_flags> {
19 IPV6ONLY = UV_TCP_IPV6ONLY
42 using Time = std::chrono::duration<unsigned int>;
43 using Bind = details::UVTCPFlags;
47 explicit TCPHandle(ConstructorAccess ca, std::shared_ptr<Loop> ref,
unsigned int f = {});
79 bool keepAlive(
bool enable =
false, Time time = Time{0});
132 template<
typename I = IPv4>
151 template<
typename I = IPv4>
158 template<
typename I = IPv4>
165 template<typename I =
IPv4>
193 template<typename I =
IPv4>
194 void connect(const std::
string &ip,
unsigned int port);
205 template<typename I =
IPv4>
244extern template Addr TCPHandle::sock<IPv6>() const noexcept;
246extern template Addr TCPHandle::peer<IPv4>() const noexcept;
247extern template Addr TCPHandle::peer<IPv6>() const noexcept;
249extern template
void TCPHandle::connect<IPv4>(const std::
string &,
unsigned int);
250extern template
void TCPHandle::connect<IPv6>(const std::
string &,
unsigned int);
252extern template
void TCPHandle::connect<IPv4>(Addr addr);
253extern template
void TCPHandle::connect<IPv6>(Addr addr);
Utility class to handle flags.
bool init()
Initializes the handle. No socket is created as of yet.
Addr sock() const noexcept
Gets the current address to which the handle is bound.
void closeReset()
Resets a TCP connection by sending a RST packet.
void open(OSSocketHandle socket)
Opens an existing file descriptor or SOCKET as a TCP handle.
bool keepAlive(bool enable=false, Time time=Time{0})
Enables/Disables TCP keep-alive.
bool noDelay(bool value=false)
Enables/Disables Nagle’s algorithm.
Addr peer() const noexcept
Gets the address of the peer connected to the handle.
bool simultaneousAccepts(bool enable=true)
Enables/Disables simultaneous asynchronous accept requests.
void bind(const std::string &ip, unsigned int port, Flags< Bind > opts=Flags< Bind >{})
Binds the handle to an address and port.
void bind(Addr addr, Flags< Bind > opts=Flags< Bind >{})
Binds the handle to an address and port.
void connect(const sockaddr &addr)
Establishes an IPv4 or IPv6 TCP connection.
void bind(const sockaddr &addr, Flags< Bind > opts=Flags< Bind >{})
Binds the handle to an address and port.
details::UVTypeWrapper< uv_os_sock_t > OSSocketHandle