1 #ifndef UVW_TCP_INCLUDE_H
2 #define UVW_TCP_INCLUDE_H
11 #include "request.hpp"
22 enum class UVTCPFlags: std::underlying_type_t<uv_tcp_flags> {
23 IPV6ONLY = UV_TCP_IPV6ONLY
48 using Time = std::chrono::duration<unsigned int>;
49 using Bind = details::UVTCPFlags;
53 explicit TCPHandle(ConstructorAccess ca, std::shared_ptr<Loop> ref,
unsigned int f = {});
76 bool noDelay(
bool value =
false);
85 bool keepAlive(
bool enable =
false, Time time = Time{0});
138 template<
typename I = IPv4>
157 template<
typename I = IPv4>
164 template<
typename I = IPv4>
171 template<
typename I = IPv4>
187 void connect(
const sockaddr &addr);
199 template<
typename I = IPv4>
200 void connect(std::string ip,
unsigned int port);
211 template<
typename I = IPv4>
228 enum { DEFAULT, FLAGS } tag;
241 extern template void TCPHandle::bind<IPv4>(std::string,
unsigned int,
Flags<Bind>);
242 extern template void TCPHandle::bind<IPv6>(std::string,
unsigned int,
Flags<Bind>);
247 extern template Addr TCPHandle::sock<IPv4>() const noexcept;
253 extern template
void TCPHandle::connect<
IPv4>(std::
string,
unsigned int);
254 extern template
void TCPHandle::connect<
IPv6>(std::
string,
unsigned int);
273 #endif // UVW_TCP_INCLUDE_H
void closeReset()
Resets a TCP connection by sending a RST packet.
void bind(const sockaddr &addr, Flags< Bind > opts=Flags< Bind >{})
Binds the handle to an address and port.
bool simultaneousAccepts(bool enable=true)
Enables/Disables simultaneous asynchronous accept requests.
void connect(const sockaddr &addr)
Establishes an IPv4 or IPv6 TCP connection.
Addr sock() const noexcept
Gets the current address to which the handle is bound.
Addr peer() const noexcept
Gets the address of the peer connected to the handle.
bool noDelay(bool value=false)
Enables/Disables Nagle’s algorithm.
Utility class to handle flags.
bool init()
Initializes the handle. No socket is created as of yet.
void open(OSSocketHandle socket)
Opens an existing file descriptor or SOCKET as a TCP handle.
details::UVTypeWrapper< uv_os_sock_t > OSSocketHandle
bool keepAlive(bool enable=false, Time time=Time{0})
Enables/Disables TCP keep-alive.