25#include "../system/sys__socket.h"
28#ifndef QB_IO_TCP_SOCKET_H_
29#define QB_IO_TCP_SOCKET_H_
31namespace qb::io::tcp {
43class QB_API
socket :
protected qb::io::socket {
52 int connect_in(
int af, std::string
const &host, uint16_t port)
noexcept;
62 int n_connect_in(
int af, std::string
const &host, uint16_t port)
noexcept;
66 using qb::io::socket::close;
67 using qb::io::socket::get_optval;
68 using qb::io::socket::is_open;
69 using qb::io::socket::local_endpoint;
70 using qb::io::socket::native_handle;
71 using qb::io::socket::peer_endpoint;
72 using qb::io::socket::release_handle;
73 using qb::io::socket::set_nonblocking;
74 using qb::io::socket::set_optval;
75 using qb::io::socket::test_nonblocking;
78 constexpr static bool is_secure() noexcept {
return false; }
121 int init(
int af = AF_INET)
noexcept;
129 int bind(qb::io::endpoint
const &ep)
noexcept;
144 int connect(qb::io::endpoint
const &ep)
noexcept;
159 int connect_v4(std::string
const &host, uint16_t port)
noexcept;
167 int connect_v6(std::string
const &host, uint16_t port)
noexcept;
234 int read(
void *dest, std::size_t len)
const noexcept;
244 int write(
const void *data, std::size_t size)
const noexcept;
int bind(qb::io::endpoint const &ep) noexcept
Bind the socket to a specific local endpoint.
int n_connect_v4(std::string const &host, uint16_t port) noexcept
Initiate a non-blocking connect to an IPv4 TCP server.
int bind(qb::io::uri const &u) noexcept
Bind the socket to an endpoint specified by a URI.
int connect(qb::io::endpoint const &ep) noexcept
Connect to a remote TCP endpoint.
void connected() noexcept
Called after a non-blocking connect attempt succeeds or needs to be finalized.
Definition socket.h:194
int n_connect_un(std::string const &path) noexcept
Initiate a non-blocking connect to a Unix domain TCP-style socket.
int connect_un(std::string const &path) noexcept
Connect to a Unix domain TCP-style socket.
int read(void *dest, std::size_t len) const noexcept
Read data from the connected TCP socket.
socket(socket &&)=default
Default move constructor.
int n_connect(qb::io::endpoint const &ep) noexcept
Initiate a non-blocking connect to a remote TCP endpoint.
int disconnect() const noexcept
Disconnect the TCP socket.
int n_connect_v6(std::string const &host, uint16_t port) noexcept
Initiate a non-blocking connect to an IPv6 TCP server.
socket & operator=(socket &&)=default
Default move assignment operator.
int connect_v4(std::string const &host, uint16_t port) noexcept
Connect to an IPv4 TCP server.
socket()=default
Default constructor.
socket(io::socket &&sock) noexcept
Constructor from a generic qb::io::socket (move semantics).
static constexpr bool is_secure() noexcept
Indicates that this socket implementation is not secure.
Definition socket.h:78
int connect_v6(std::string const &host, uint16_t port) noexcept
Connect to an IPv6 TCP server.
int init(int af=AF_INET) noexcept
Initialize (open) the TCP socket.
int connect(uri const &u) noexcept
Connect to a remote TCP endpoint specified by a URI.
int n_connect(uri const &u) noexcept
Initiate a non-blocking connect to a remote TCP endpoint specified by a URI.
socket(socket const &)=delete
Deleted copy constructor.
socket & operator=(io::socket &&sock) noexcept
Move assignment operator from a generic qb::io::socket.
int write(const void *data, std::size_t size) const noexcept
Write data to the connected TCP socket.
Class for parsing, manipulating, and representing URIs.
Definition uri.h:181
URI parsing and manipulation utilities.