1#ifndef UVW_TCP_INCLUDE_H
2#define UVW_TCP_INCLUDE_H
20enum class uvw_tcp_flags : std::underlying_type_t<uv_tcp_flags> {
21 IPV6ONLY = UV_TCP_IPV6ONLY,
45 using time = std::chrono::duration<unsigned int>;
46 using tcp_flags = details::uvw_tcp_flags;
50 explicit tcp_handle(loop::token token, std::shared_ptr<loop> ref,
unsigned int f = {});
85 bool keep_alive(
bool enable = false, time val = time{0});
118 int bind(
const sockaddr &addr, tcp_flags opts = tcp_flags::_UVW_ENUM);
136 int bind(
const std::string &ip,
unsigned int port, tcp_flags opts = tcp_flags::_UVW_ENUM);
192 int connect(const std::
string &ip,
unsigned int port);
bool keep_alive(bool enable=false, time val=time{0})
Enables/Disables TCP keep-alive.
int init() final
Initializes the handle. No socket is created as of yet.
int bind(const sockaddr &addr, tcp_flags opts=tcp_flags::_UVW_ENUM)
Binds the handle to an address and port.
int bind(const std::string &ip, unsigned int port, tcp_flags opts=tcp_flags::_UVW_ENUM)
Binds the handle to an address and port.
int connect(const sockaddr &addr)
Establishes an IPv4 or IPv6 TCP connection.
int close_reset()
Resets a TCP connection by sending a RST packet.
int open(os_socket_handle socket)
Opens an existing file descriptor or SOCKET as a TCP handle.
bool simultaneous_accepts(bool enable=true)
Enables/Disables simultaneous asynchronous accept requests.
bool no_delay(bool value=false)
Enables/Disables Nagle’s algorithm.
socket_address peer() const noexcept
Gets the address of the peer connected to the handle.
socket_address sock() const noexcept
Gets the current address to which the handle is bound.
int bind(socket_address addr, tcp_flags opts=tcp_flags::_UVW_ENUM)
Binds the handle to an address and port.
details::uv_type_wrapper< uv_os_sock_t > os_socket_handle