26#ifndef MYSQL_HARNESS_NET_TS_SOCKET_H_ 
   27#define MYSQL_HARNESS_NET_TS_SOCKET_H_ 
   31#include <system_error> 
   41#include <netinet/in.h>    
   42#include <netinet/ip6.h>   
   43#include <netinet/tcp.h>   
   48#include <sys/sockio.h>   
   66namespace socket_option {
 
   76template <
int Level, 
int Name, 
class T, 
class V = T>
 
   89  template <
typename Protocol>
 
   94  template <
typename Protocol>
 
   99  template <
typename Protocol>
 
  101    return std::addressof(
value_);
 
  104  template <
typename Protocol>
 
  106    return std::addressof(
value_);
 
  109  template <
typename Protocol>
 
  114  template <
class Protocol>
 
  116    if (s != 
sizeof(
value_)) {
 
  117      throw std::length_error(
"size != sizeof(value_)");
 
  128template <
int Level, 
int Name>
 
  134template <
int Level, 
int Name>
 
  195    std::array<impl::socket::iovec_base, 16> 
iov_{};
 
  198    template <
class BufferSequence>
 
  199    explicit msg_hdr(
const BufferSequence &buffers)
 
  201      const size_t iovs_capacity = 
iov_.size();
 
  206           (i < iovs_capacity) && (bufcur != bufend); ++i, ++bufcur) {
 
  209            const_cast<CHAR *
>(
reinterpret_cast<const CHAR *
>(bufcur->data()));
 
  210        iov_[i].len = 
static_cast<DWORD
>(bufcur->size());
 
  212        iov_[i] = {
const_cast<void *
>(bufcur->data()), bufcur->size()};
 
  217      this->lpBuffers = 
iov_.data();
 
  218      this->dwBufferCount = 
static_cast<DWORD
>(i);
 
  220      this->msg_iov = 
iov_.data();
 
  221      this->msg_iovlen = i;
 
  230    template <
class endpo
int_type>
 
  233      this->
name = 
static_cast<SOCKADDR *
>(ep.data());
 
  234      this->namelen = ep.capacity();
 
  236      this->msg_name = ep.data();
 
  237      this->msg_namelen = ep.capacity();
 
  244    template <
class endpo
int_type>
 
  247      ep.resize(this->namelen);
 
  249      ep.resize(this->msg_namelen);
 
  256    template <
class endpo
int_type>
 
  260          const_cast<SOCKADDR *
>(
static_cast<const SOCKADDR *
>(ep.data()));
 
  261      this->namelen = ep.size();
 
  263      this->msg_name = 
const_cast<void *
>(ep.data());
 
  264      this->msg_namelen = ep.size();
 
  280      : 
value_{e, 
static_cast<decltype(
value_.l_linger)
>(t.count())} {}
 
  289    value_.l_linger = 
static_cast<int>(t.count());
 
  292  template <
class Protocol>
 
  297  template <
class Protocol>
 
  302  template <
class Protocol>
 
  304    return std::addressof(
value_);
 
  307  template <
class Protocol>
 
  309    return std::addressof(
value_);
 
  312  template <
class Protocol>
 
  317  template <
class Protocol>
 
  319    if (s != 
sizeof(
value_)) {
 
  320      throw std::length_error(
"size != sizeof(::linger)");
 
  350        io_ctx_{std::move(rhs.io_ctx_)} {}
 
  407    if (!res) 
return res;
 
  462      static_cast<char>(-1)
 
  470template <
typename Protocol>
 
  489    if (
this == std::addressof(rhs)) {
 
  509        protocol.family(), protocol.type() | 
flags, protocol.protocol());
 
  512    if ((
flags & SOCK_NONBLOCK) != 0) {
 
  517    return assign(protocol, res.value());
 
  534        reinterpret_cast<const struct 
sockaddr *
>(endpoint.data()),
 
  540                                                 socklen_t *endpoint_size,
 
  547      } 
else if (res.error() != std::errc::operation_not_supported) {
 
  557    return {std::in_place, io_ctx, 
protocol_, std::move(res.value())};
 
  562    return accept(io_ctx, 
static_cast<struct 
sockaddr *
>(
nullptr), 
nullptr,
 
  569    socklen_t endpoint_len = endpoint.capacity();
 
  571    auto res = 
accept(io_ctx, 
static_cast<struct 
sockaddr *
>(endpoint.data()),
 
  572                      &endpoint_len, 
flags);
 
  574      endpoint.resize(endpoint_len);
 
  584  template <
typename SettableSocketOption>
 
  586      const SettableSocketOption &option) {
 
  592  template <
typename GettableSocketOption>
 
  594      GettableSocketOption &option)
 const {
 
  595    socklen_t option_len = option.size(
protocol_);
 
  600    if (!res) 
return res;
 
  609    size_t ep_len = ep.capacity();
 
  623    size_t ep_len = ep.capacity();
 
  636  template <
unsigned long Name, 
class T>
 
  646    constexpr unsigned long name()
 const { 
return Name; }
 
  667  template <
class IoControlCommand>
 
  679    if (ioc.
value() < 0) {
 
  684    return static_cast<size_t>(ioc.
value());
 
  699                                               static_cast<int>(st));
 
  710template <
typename Protocol>
 
  735      auto res = 
open(endpoint.protocol());
 
  736      if (!res) 
return res;
 
  740        reinterpret_cast<const struct 
sockaddr *
>(endpoint.data()),
 
  744  template <
class CompletionToken>
 
  749      auto res = 
open(endpoint.protocol());
 
  751        init.completion_handler(res.error());
 
  759                                    std::move(
init.completion_handler)]() {
 
  761      const auto old_non_blocking = native_non_blocking();
 
  762      if (old_non_blocking == false) native_non_blocking(true);
 
  764      auto res = connect(endpoint);
 
  767      if (old_non_blocking == false) native_non_blocking(false);
 
  772        const auto ec = res.error();
 
  775             make_error_condition(std::errc::operation_in_progress)) 
 
  776            && (ec != make_error_condition(
 
  777                          std::errc::operation_would_block)) ) {
 
  780          get_executor().context().async_wait(
 
  781              native_handle(), net::socket_base::wait_write,
 
  782              [this, __compl_handler = std::move(__compl_handler)](
 
  783                  std::error_code ec) mutable {
 
  790                net::socket_base::error so_error;
 
  792                auto res = get_option(so_error);
 
  794                  __compl_handler(res.error());
 
  800                    impl::socket::make_error_code(so_error.value()));
 
  806    return init.result.get();
 
  817  template <
typename SettableSocketOption>
 
  819      const SettableSocketOption &option) {
 
  820    return __base::set_option(option);
 
  823  template <
typename GettableSocketOption>
 
  825      GettableSocketOption &option)
 const {
 
  834    return __base::release();
 
  837  constexpr bool is_open()
 const { 
return __base::is_open(); }
 
  840    return __base::local_endpoint();
 
  844    return __base::remote_endpoint();
 
  848    return __base::available();
 
  854    return __base::non_blocking(
mode);
 
  872#if defined(ALL_COMPILERS_FULLY_SUPPORT_CPP14) 
  890  template <
typename CompletionToken>
 
  891  auto async_wait(
wait_type w, CompletionToken &&token) {
 
  894    get_executor().context().async_wait(
 
  896        [__compl_handler = std::move(
init.completion_handler)](
 
  897            std::error_code ec) 
mutable { __compl_handler(ec); });
 
  899    return init.result.get();
 
  908  template <
typename CompletionToken>
 
  909  typename async_result<std::decay_t<CompletionToken>,
 
  910                        void(std::error_code)>::return_type
 
  914    using async_completion_handler_type =
 
  915        typename decltype(
init)::completion_handler_type;
 
  920      explicit ClosureType(async_completion_handler_type &&compl_handler)
 
  922                std::forward<decltype(compl_handler)>(compl_handler)} {}
 
  924      void operator()(std::error_code ec) { compl_handler_(ec); }
 
  927      async_completion_handler_type compl_handler_;
 
  935    get_executor().context().async_wait(
 
  937        ClosureType(std::forward<async_completion_handler_type>(
 
  938            init.completion_handler)));
 
  940    return init.result.get();
 
  970template <
typename Protocol>
 
  999  template <
class MutableBufferSequence>
 
 1004    return this->get_executor().context().socket_service()->recvmsg(
 
 1008  template <
class MutableBufferSequence>
 
 1010      const MutableBufferSequence &buffers) {
 
 1011    return receive(buffers, 0);
 
 1014  template <
class MutableBufferSequence>
 
 1016      const MutableBufferSequence &buffers, 
endpoint_type &sender,
 
 1021    auto res = this->get_executor().context().socket_service()->recvmsg(
 
 1032  template <
class MutableBufferSequence>
 
 1034      const MutableBufferSequence &buffers, 
endpoint_type &sender) {
 
 1035    return receive_from(buffers, sender, 0);
 
 1038  template <
class MutableBufferSequence>
 
 1040      const MutableBufferSequence &buffers) {
 
 1041    return receive(buffers);
 
 1044  template <
class ConstBufferSequence>
 
 1051    return this->get_executor().context().socket_service()->sendmsg(
 
 1055  template <
class ConstBufferSequence>
 
 1057      const ConstBufferSequence &buffers) {
 
 1060    return send(buffers, 0);
 
 1063  template <
class ConstBufferSequence>
 
 1065      const ConstBufferSequence &buffers, 
const endpoint_type &recipient,
 
 1072    return this->get_executor().context().socket_service()->sendmsg(
 
 1076  template <
class ConstBufferSequence>
 
 1078      const ConstBufferSequence &buffers, 
const endpoint_type &recipient) {
 
 1081    return send_to(buffers, recipient, 0);
 
 1084  template <
class ConstBufferSequence>
 
 1086      const ConstBufferSequence &buffers) {
 
 1089    return send(buffers);
 
 1097  template <
class MutableBufferSequence, 
class CompletionToken>
 
 1100                     CompletionToken &&token) {
 
 1108      return init.result.get();
 
 1111    this->get_executor().context().async_wait(
 
 1113        [
this, __compl_handler = std::move(
init.completion_handler), &buffers,
 
 1114         __fd = this->native_handle(),
 
 1115         __flags = 
flags](std::error_code ec) 
mutable {
 
 1117            __compl_handler(ec, 0);
 
 1123          auto res = this->get_executor().context().socket_service()->recvmsg(
 
 1124              __fd, msgs, __flags);
 
 1126            __compl_handler(res.error(), 0);
 
 1128            __compl_handler({}, res.value());
 
 1132    return init.result.get();
 
 1135  template <
class MutableBufferSequence, 
class CompletionToken>
 
 1137                     CompletionToken &&token) {
 
 1138    return async_receive(buffers, 0, std::forward<CompletionToken>(token));
 
 1143template <
typename Protocol>
 
 1170  template <
class MutableBufferSequence>
 
 1177    auto res = this->get_executor().context().socket_service()->recvmsg(
 
 1180    if (res && res.value() == 0) {
 
 1188  template <
class MutableBufferSequence>
 
 1190      const MutableBufferSequence &buffers) {
 
 1191    return receive(buffers, 0);
 
 1194  template <
class MutableBufferSequence>
 
 1196      const MutableBufferSequence &buffers) {
 
 1197    return receive(buffers);
 
 1200  template <
class ConstBufferSequence>
 
 1209    auto res = this->get_executor().context().socket_service()->sendmsg(
 
 1212    if (res && res.value() == 0) {
 
 1220  template <
class ConstBufferSequence>
 
 1222      const ConstBufferSequence &buffers) {
 
 1225    return send(buffers, 0);
 
 1228  template <
class ConstBufferSequence>
 
 1230      const ConstBufferSequence &buffers) {
 
 1233    return send(buffers);
 
 1241  template <
class MutableBufferSequence, 
class CompletionToken>
 
 1244                     CompletionToken &&token) {
 
 1251      return init.result.get();
 
 1255      init.completion_handler({}, 0);
 
 1257      return init.result.get();
 
 1272    using compl_handler_type = 
typename decltype(
init)::completion_handler_type;
 
 1277                compl_handler_type &&compl_handler,
 
 1278                const MutableBufferSequence &buffers,
 
 1281          : socket_service_{socket_service},
 
 1282            compl_handler_(std::move(compl_handler)),
 
 1287      Completor(
const Completor &) = 
delete;
 
 1288      Completor(Completor &&) = 
default;
 
 1290      void operator()(std::error_code ec) {
 
 1292          compl_handler_(ec, 0);
 
 1298        const auto res = socket_service_->recvmsg(native_handle_, msgs, flags_);
 
 1300          compl_handler_(res.error(), 0);
 
 1301        } 
else if (res.value() == 0) {
 
 1305          compl_handler_({}, res.value());
 
 1313      compl_handler_type compl_handler_;
 
 1314      const MutableBufferSequence &buffers_;
 
 1319    this->get_executor().context().async_wait(
 
 1321        Completor(this->get_executor().context().socket_service(),
 
 1322                  std::move(
init.completion_handler), buffers,
 
 1323                  this->native_handle(), 
flags));
 
 1325    return init.result.get();
 
 1328  template <
class MutableBufferSequence, 
class CompletionToken>
 
 1330                     CompletionToken &&token) {
 
 1331    return async_receive(buffers, 0, std::forward<CompletionToken>(token));
 
 1334  template <
class ConstBufferSequence, 
class CompletionToken>
 
 1342      init.completion_handler({}, 0);
 
 1344      return init.result.get();
 
 1348    using compl_handler_type = 
typename decltype(
init)::completion_handler_type;
 
 1353                compl_handler_type &&compl_handler,
 
 1354                const ConstBufferSequence &buffers,
 
 1357          : socket_service_{socket_service},
 
 1358            compl_handler_(std::move(compl_handler)),
 
 1363      Completor(
const Completor &) = 
delete;
 
 1364      Completor(Completor &&) = 
default;
 
 1366      void operator()(std::error_code ec) {
 
 1368          compl_handler_(ec, 0);
 
 1374        const auto res = socket_service_->sendmsg(native_handle_, msgs, flags_);
 
 1376          compl_handler_(res.error(), 0);
 
 1378          compl_handler_({}, res.value());
 
 1385      compl_handler_type compl_handler_;
 
 1386      const ConstBufferSequence &buffers_;
 
 1392    this->get_executor().context().async_wait(
 
 1394        Completor(this->get_executor().context().socket_service(),
 
 1395                  std::move(
init.completion_handler), buffers,
 
 1396                  this->native_handle(), 
flags));
 
 1398    return init.result.get();
 
 1401  template <
class ConstBufferSequence, 
class CompletionToken>
 
 1402  auto async_send(
const ConstBufferSequence &buffers, CompletionToken &&token) {
 
 1405    return async_send(buffers, 0, std::forward<CompletionToken>(token));
 
 1410template <
typename AcceptableProtocol>
 
 1436    return __base::assign(protocol, native_acceptor);
 
 1440    return __base::release();
 
 1445  constexpr bool is_open()
 const { 
return __base::is_open(); }
 
 1451  template <
typename SettableSocketOption>
 
 1453      const SettableSocketOption &option) {
 
 1454    return __base::set_option(option);
 
 1457  template <
typename GettableSocketOption>
 
 1459      GettableSocketOption &option)
 const {
 
 1466    return __base::non_blocking(
mode);
 
 1484    return __base::local_endpoint();
 
 1501      if (accept_res || enable_connection_aborted() ||
 
 1502          accept_res.error() !=
 
 1511    return accept(get_executor().context(), endpoint, 
flags);
 
 1521      if (accept_res || enable_connection_aborted() ||
 
 1522          accept_res.error() !=
 
 1529  template <
class CompletionToken>
 
 1537        [
this, __compl_handler = std::move(
init.completion_handler),
 
 1539         &io_ctx](std::error_code ec) 
mutable {
 
 1546            auto res = this->get_executor().context().socket_service()->accept(
 
 1547                __fd, 
nullptr, 
nullptr);
 
 1549            if (!res && !enable_connection_aborted() &&
 
 1556              __compl_handler(res.error(), 
socket_type(io_ctx));
 
 1558              __compl_handler({}, 
socket_type{io_ctx, __protocol, res.value()});
 
 1564    return init.result.get();
 
 1567  template <
class CompletionToken>
 
 1569    return async_accept(get_executor().context(), endpoint,
 
 1570                        std::forward<CompletionToken>(token));
 
 1584  template <
class CompletionToken>
 
 1586                    CompletionToken &&token) {
 
 1595        [
this, __compl_handler = std::move(
init.completion_handler),
 
 1596         __protocol = protocol_, __fd = 
native_handle(), &__ep = endpoint,
 
 1597         &io_ctx](std::error_code ec) 
mutable {
 
 1604            socklen_t endpoint_len = __ep.capacity();
 
 1606            auto res = this->get_executor().context().socket_service()->accept(
 
 1607                __fd, 
static_cast<sockaddr *
>(__ep.data()), &endpoint_len);
 
 1609            if (!res && !enable_connection_aborted() &&
 
 1616              __compl_handler(res.error(), 
socket_type(io_ctx));
 
 1618              __ep.resize(endpoint_len);
 
 1620              __compl_handler({}, 
socket_type{io_ctx, __protocol, res.value()});
 
 1626    return init.result.get();
 
 1629  template <
class CompletionToken>
 
 1631    return async_accept(get_executor().context(),
 
 1632                        std::forward<CompletionToken>(token));
 
 1639#if defined(ALL_COMPILERS_FULLY_SUPPORT_CPP14) 
 1657  template <
typename CompletionToken>
 
 1658  auto async_wait(
wait_type w, CompletionToken &&token) {
 
 1661    get_executor().context().async_wait(
 
 1663        [__compl_handler = std::move(
init.completion_handler)](
 
 1664            std::error_code ec) 
mutable { __compl_handler(ec); });
 
 1666    return init.result.get();
 
 1675  template <
typename CompletionToken>
 
 1676  typename async_result<std::decay_t<CompletionToken>,
 
 1677                        void(std::error_code)>::return_type
 
 1681    using async_completion_handler_type =
 
 1682        typename decltype(
init)::completion_handler_type;
 
 1687      explicit ClosureType(async_completion_handler_type &&compl_handler)
 
 1689                std::forward<decltype(compl_handler)>(compl_handler)} {}
 
 1691      void operator()(std::error_code ec) { compl_handler_(ec); }
 
 1694      async_completion_handler_type compl_handler_;
 
 1702    get_executor().context().async_wait(
 
 1704        ClosureType(std::forward<async_completion_handler_type>(
 
 1705            init.completion_handler)));
 
 1707    return init.result.get();
 
 1713  bool enable_connection_aborted_{
false};
 
 1730template <
class Protocol, 
class Endpo
intSequence, 
class ConnectCondition>
 
 1733    ConnectCondition c) {
 
 1734  return connect(s, std::begin(endpoints), std::end(endpoints), c);
 
 1746template <
class Protocol, 
class Endpo
intSequence>
 
 1749  return connect(s, endpoints, [](
auto, 
auto) { 
return true; });
 
 1764template <
class Protocol, 
class InputIterator, 
class ConnectCondition>
 
 1767    ConnectCondition c) {
 
 1771  for (InputIterator cur = first; cur != 
last; ++cur) {
 
 1773    if (!c(ec, *cur)) 
continue;
 
 1775    auto res = s.
close();
 
 1781    res = s.
open(
typename Protocol::endpoint(*cur).protocol());
 
 1798template <
class Protocol, 
class InputIterator, 
class ConnectCondition>
 
 1801  return connect(s, first, 
last, [](
auto, 
auto) { 
return true; });
 
 1806#if defined(MYSQL_HARNESS_HEADER_ONLY) 
Definition: protocol.h:33
 
Definition: executor.h:72
 
stdx::expected< size_t, std::error_code > send_to(const ConstBufferSequence &buffers, const endpoint_type &recipient)
Definition: socket.h:1077
 
stdx::expected< size_t, std::error_code > receive_from(const MutableBufferSequence &buffers, endpoint_type &sender)
Definition: socket.h:1033
 
stdx::expected< bool, error_type > shutdown(socket_base::shutdown_type st) const
Definition: socket.h:1092
 
basic_datagram_socket & operator=(const basic_datagram_socket &)=delete
 
basic_datagram_socket(const basic_datagram_socket &)=delete
 
basic_datagram_socket(io_context &ctx, const protocol_type &proto)
Definition: socket.h:981
 
stdx::expected< size_t, std::error_code > receive(const MutableBufferSequence &buffers, socket_base::message_flags flags)
Definition: socket.h:1000
 
basic_datagram_socket(io_context &ctx, const protocol_type &protocol, const native_handle_type &native_handle)
Definition: socket.h:995
 
stdx::expected< size_t, std::error_code > receive_from(const MutableBufferSequence &buffers, endpoint_type &sender, socket_base::message_flags flags)
Definition: socket.h:1015
 
basic_datagram_socket(basic_datagram_socket &&other)=default
 
stdx::expected< size_t, std::error_code > receive(const MutableBufferSequence &buffers)
Definition: socket.h:1009
 
stdx::expected< size_t, std::error_code > send(const ConstBufferSequence &buffers, socket_base::message_flags flags)
Definition: socket.h:1045
 
auto async_receive(const MutableBufferSequence &buffers, socket_base::message_flags flags, CompletionToken &&token)
Definition: socket.h:1098
 
basic_datagram_socket & operator=(basic_datagram_socket &&)=default
 
stdx::expected< size_t, std::error_code > read_some(const MutableBufferSequence &buffers)
Definition: socket.h:1039
 
stdx::expected< size_t, std::error_code > send(const ConstBufferSequence &buffers)
Definition: socket.h:1056
 
basic_datagram_socket(io_context &ctx)
Definition: socket.h:980
 
stdx::expected< size_t, std::error_code > send_to(const ConstBufferSequence &buffers, const endpoint_type &recipient, socket_base::message_flags flags)
Definition: socket.h:1064
 
~basic_datagram_socket()=default
 
stdx::expected< size_t, std::error_code > write_some(const ConstBufferSequence &buffers)
Definition: socket.h:1085
 
auto async_receive(const MutableBufferSequence &buffers, CompletionToken &&token)
Definition: socket.h:1136
 
Definition: socket.h:1412
 
basic_socket_acceptor(io_context &ctx)
Definition: socket.h:1423
 
typename protocol_type::endpoint endpoint_type
Definition: socket.h:1420
 
auto async_accept(io_context &io_ctx, endpoint_type &endpoint, CompletionToken &&token)
accept a connection with endpoint async'.
Definition: socket.h:1585
 
std::error_code error_type
Definition: socket.h:1421
 
stdx::expected< endpoint_type, error_type > local_endpoint() const
Definition: socket.h:1483
 
bool native_non_blocking() const
Definition: socket.h:1469
 
bool non_blocking() const
Definition: socket.h:1463
 
stdx::expected< void, error_type > assign(const protocol_type &protocol, const native_handle_type &native_acceptor)
Definition: socket.h:1433
 
stdx::expected< native_handle_type, error_type > release()
Definition: socket.h:1439
 
async_result< std::decay_t< CompletionToken >, void(std::error_code)>::return_type async_wait(wait_type w, CompletionToken &&token)
Definition: socket.h:1678
 
stdx::expected< socket_type, error_type > accept(int flags=0)
Definition: socket.h:1491
 
native_handle_type native_handle() const
Definition: socket.h:1443
 
stdx::expected< void, error_type > listen(int backlog)
Definition: socket.h:1479
 
stdx::expected< void, error_type > open(const protocol_type &protocol=protocol_type(), int flags=0)
Definition: socket.h:1428
 
AcceptableProtocol protocol_type
Definition: socket.h:1418
 
stdx::expected< socket_type, error_type > accept(endpoint_type &endpoint, int flags=0)
Definition: socket.h:1509
 
typename protocol_type::socket socket_type
Definition: socket.h:1419
 
stdx::expected< void, error_type > bind(const endpoint_type &endpoint)
Definition: socket.h:1475
 
stdx::expected< socket_type, error_type > accept(io_context &io_ctx, endpoint_type &endpoint, int flags=0)
Definition: socket.h:1514
 
stdx::expected< void, error_type > close()
Definition: socket.h:1447
 
auto async_accept(endpoint_type &endpoint, CompletionToken &&token)
Definition: socket.h:1568
 
executor_type get_executor() noexcept
Definition: socket.h:1426
 
protocol_type protocol_
Definition: socket.h:1712
 
stdx::expected< void, std::error_code > wait(socket_base::wait_type wt)
Definition: socket.h:1635
 
auto async_accept(CompletionToken &&token)
Definition: socket.h:1630
 
stdx::expected< void, error_type > cancel()
Definition: socket.h:1449
 
bool enable_connection_aborted() const
Definition: socket.h:1489
 
stdx::expected< void, std::error_code > native_non_blocking(bool mode)
Definition: socket.h:1471
 
auto async_accept(io_context &io_ctx, CompletionToken &&token)
Definition: socket.h:1530
 
stdx::expected< void, error_type > get_option(GettableSocketOption &option) const
Definition: socket.h:1458
 
stdx::expected< void, std::error_code > non_blocking(bool mode)
Definition: socket.h:1465
 
constexpr bool is_open() const
Definition: socket.h:1445
 
stdx::expected< socket_type, error_type > accept(io_context &io_ctx, int flags=0)
Definition: socket.h:1495
 
stdx::expected< void, error_type > set_option(const SettableSocketOption &option)
Definition: socket.h:1452
 
constexpr IoControl(value_type v)
Definition: socket.h:643
 
constexpr value_type value() const
Definition: socket.h:650
 
constexpr IoControl()
Definition: socket.h:641
 
T value_type
Definition: socket.h:639
 
constexpr void * data()
Definition: socket.h:648
 
constexpr unsigned long name() const
Definition: socket.h:646
 
value_type val_
Definition: socket.h:653
 
template-less base-class of basic_socket_impl.
Definition: socket.h:335
 
stdx::expected< void, std::error_code > native_non_blocking(bool mode)
Definition: socket.h:394
 
io_context * io_ctx_
Definition: socket.h:466
 
basic_socket_impl_base & operator=(const basic_socket_impl_base &rhs)=delete
 
bool non_blocking_
Definition: socket.h:452
 
stdx::expected< void, std::error_code > non_blocking(bool mode)
Definition: socket.h:374
 
constexpr bool non_blocking() const
Definition: socket.h:372
 
constexpr native_handle_type native_handle() const noexcept
Definition: socket.h:364
 
constexpr basic_socket_impl_base(io_context &ctx)
Definition: socket.h:340
 
stdx::expected< native_handle_type, std::error_code > release()
Definition: socket.h:442
 
stdx::expected< void, std::error_code > cancel()
Definition: socket.h:432
 
native_handle_type native_handle_
Definition: socket.h:450
 
stdx::expected< void, std::error_code > close()
Definition: socket.h:416
 
char native_non_blocking_
Definition: socket.h:453
 
executor_type get_executor() noexcept
Definition: socket.h:414
 
impl::socket::native_handle_type native_handle_type
Definition: socket.h:337
 
basic_socket_impl_base(const basic_socket_impl_base &rhs)=delete
 
basic_socket_impl_base & operator=(basic_socket_impl_base &&rhs) noexcept
Definition: socket.h:352
 
bool native_non_blocking() const
Definition: socket.h:384
 
basic_socket_impl_base(basic_socket_impl_base &&rhs) noexcept
Definition: socket.h:345
 
constexpr bool is_open() const noexcept
Definition: socket.h:368
 
~basic_socket_impl_base()=default
 
typename protocol_type::socket socket_type
Definition: socket.h:479
 
basic_socket_impl(basic_socket_impl &&rhs)=default
 
Protocol protocol_type
Definition: socket.h:476
 
stdx::expected< endpoint_type, error_type > local_endpoint() const
Definition: socket.h:607
 
stdx::expected< void, error_type > bind(const endpoint_type &endpoint)
Definition: socket.h:531
 
stdx::expected< socket_type, error_type > accept(io_context &io_ctx, int flags=0)
Definition: socket.h:560
 
~basic_socket_impl()
Definition: socket.h:499
 
stdx::expected< endpoint_type, error_type > remote_endpoint() const
Definition: socket.h:621
 
stdx::expected< void, error_type > open(const protocol_type &protocol=protocol_type(), int flags=0)
Definition: socket.h:503
 
stdx::expected< void, std::error_code > wait(socket_base::wait_type wt)
Definition: socket.h:702
 
stdx::expected< bool, error_type > at_mark() const
Definition: socket.h:687
 
typename protocol_type::endpoint endpoint_type
Definition: socket.h:477
 
stdx::expected< void, error_type > listen(int backlog=socket_base::max_listen_connections)
Definition: socket.h:579
 
basic_socket_impl(const basic_socket_impl &)=delete
 
stdx::expected< void, error_type > assign(const protocol_type &protocol, const native_handle_type &native_handle)
Definition: socket.h:520
 
stdx::expected< void, error_type > get_option(GettableSocketOption &option) const
Definition: socket.h:593
 
stdx::expected< void, error_type > set_option(const SettableSocketOption &option)
Definition: socket.h:585
 
constexpr basic_socket_impl(io_context &ctx) noexcept
Definition: socket.h:481
 
protocol_type protocol_
Definition: socket.h:707
 
std::error_code error_type
Definition: socket.h:478
 
stdx::expected< void, error_type > io_control(IoControlCommand &cmd) const
Definition: socket.h:668
 
stdx::expected< void, error_type > shutdown(socket_base::shutdown_type st) const
Definition: socket.h:696
 
basic_socket_impl & operator=(basic_socket_impl &&rhs) noexcept
Definition: socket.h:488
 
stdx::expected< socket_type, error_type > accept(io_context &io_ctx, endpoint_type &endpoint, int flags=0)
Definition: socket.h:566
 
stdx::expected< socket_type, error_type > accept(io_context &io_ctx, struct sockaddr *endpoint_data, socklen_t *endpoint_size, int flags=0)
Definition: socket.h:538
 
stdx::expected< size_t, error_type > available() const
Definition: socket.h:673
 
basic_socket_impl & operator=(const basic_socket_impl &)=delete
 
stdx::expected< void, error_type > cancel()
Definition: socket.h:831
 
stdx::expected< size_t, error_type > available() const
Definition: socket.h:847
 
stdx::expected< void, std::error_code > native_non_blocking(bool mode)
Definition: socket.h:859
 
stdx::expected< void, error_type > set_option(const SettableSocketOption &option)
Definition: socket.h:818
 
bool non_blocking() const
Definition: socket.h:851
 
Protocol protocol_type
Definition: socket.h:716
 
stdx::expected< native_handle_type, error_type > release()
Definition: socket.h:833
 
stdx::expected< void, error_type > close()
Definition: socket.h:829
 
async_result< std::decay_t< CompletionToken >, void(std::error_code)>::return_type async_wait(wait_type w, CompletionToken &&token)
Definition: socket.h:911
 
executor_type get_executor() noexcept
Definition: socket.h:721
 
stdx::expected< void, error_type > connect(const endpoint_type &endpoint)
Definition: socket.h:733
 
basic_socket(basic_socket &&other)=default
 
constexpr bool is_open() const
Definition: socket.h:837
 
native_handle_type native_handle() const noexcept
Definition: socket.h:813
 
stdx::expected< void, error_type > shutdown(socket_base::shutdown_type st) const
Definition: socket.h:867
 
auto async_connect(const endpoint_type &endpoint, CompletionToken &&token)
Definition: socket.h:745
 
bool native_non_blocking() const
Definition: socket.h:857
 
stdx::expected< void, error_type > bind(const endpoint_type &endpoint)
Definition: socket.h:809
 
basic_socket & operator=(basic_socket &&)=default
 
basic_socket(const basic_socket &)=delete
 
stdx::expected< void, error_type > assign(const protocol_type &protocol, const native_handle_type &native_handle)
Definition: socket.h:723
 
basic_socket & operator=(const basic_socket &)=delete
 
basic_socket(io_context &ctx, const protocol_type &proto)
Definition: socket.h:947
 
basic_socket(io_context &ctx, const protocol_type &proto, const native_handle_type &native_handle)
Definition: socket.h:950
 
stdx::expected< void, error_type > get_option(GettableSocketOption &option) const
Definition: socket.h:824
 
stdx::expected< endpoint_type, error_type > remote_endpoint() const
Definition: socket.h:843
 
stdx::expected< void, error_type > open(const protocol_type &protocol=protocol_type(), int flags=0)
Definition: socket.h:728
 
basic_socket(io_context &ctx)
Definition: socket.h:945
 
stdx::expected< endpoint_type, error_type > local_endpoint() const
Definition: socket.h:839
 
stdx::expected< void, std::error_code > non_blocking(bool mode)
Definition: socket.h:853
 
stdx::expected< void, std::error_code > wait(socket_base::wait_type wt)
Definition: socket.h:863
 
Definition: socket.h:1144
 
stdx::expected< size_t, std::error_code > send(const ConstBufferSequence &buffers)
Definition: socket.h:1221
 
stdx::expected< size_t, std::error_code > read_some(const MutableBufferSequence &buffers)
Definition: socket.h:1195
 
stdx::expected< void, error_type > shutdown(socket_base::shutdown_type st) const
Definition: socket.h:1236
 
stdx::expected< size_t, std::error_code > receive(const MutableBufferSequence &buffers)
Definition: socket.h:1189
 
basic_stream_socket(const basic_stream_socket &)=delete
 
auto async_send(const ConstBufferSequence &buffers, CompletionToken &&token)
Definition: socket.h:1402
 
auto async_receive(const MutableBufferSequence &buffers, CompletionToken &&token)
Definition: socket.h:1329
 
stdx::expected< size_t, std::error_code > write_some(const ConstBufferSequence &buffers)
Definition: socket.h:1229
 
basic_stream_socket(io_context &ctx, const protocol_type &protocol, const native_handle_type &native_handle)
Definition: socket.h:1166
 
basic_stream_socket(basic_stream_socket &&other)=default
 
stdx::expected< size_t, std::error_code > receive(const MutableBufferSequence &buffers, socket_base::message_flags flags)
Definition: socket.h:1171
 
auto async_send(const ConstBufferSequence &buffers, socket_base::message_flags flags, CompletionToken &&token)
Definition: socket.h:1335
 
stdx::expected< size_t, std::error_code > send(const ConstBufferSequence &buffers, socket_base::message_flags flags)
Definition: socket.h:1201
 
basic_stream_socket(io_context &ctx)
Definition: socket.h:1153
 
basic_stream_socket & operator=(basic_stream_socket &&)=default
 
~basic_stream_socket()=default
 
auto async_receive(const MutableBufferSequence &buffers, socket_base::message_flags flags, CompletionToken &&token)
Definition: socket.h:1242
 
basic_stream_socket & operator=(const basic_stream_socket &)=delete
 
basic_stream_socket(io_context &ctx, const protocol_type &proto)
Definition: socket.h:1154
 
Definition: socket_service_base.h:48
 
virtual stdx::expected< void, error_type > ioctl(native_handle_type native_handle, unsigned long cmd, void *data) const =0
 
virtual stdx::expected< void, error_type > bind(native_handle_type native_handle, const struct sockaddr *addr, size_t addr_len) const =0
 
virtual stdx::expected< void, error_type > getsockopt(native_handle_type native_handle, int level, int optname, void *optval, socklen_t *optlen) const =0
 
virtual stdx::expected< void, error_type > getsockname(native_handle_type native_handle, struct sockaddr *addr, size_t *addr_len) const =0
 
virtual stdx::expected< native_handle_type, error_type > socket(int family, int sock_type, int protocol) const =0
 
virtual stdx::expected< void, error_type > close(native_handle_type native_handle) const =0
 
virtual stdx::expected< void, error_type > getpeername(native_handle_type native_handle, struct sockaddr *addr, size_t *addr_len) const =0
 
virtual stdx::expected< native_handle_type, error_type > accept(native_handle_type native_handle, struct sockaddr *addr, socklen_t *addr_len) const =0
 
virtual stdx::expected< native_handle_type, error_type > accept4(native_handle_type native_handle, struct sockaddr *addr, socklen_t *addr_len, int flags=0) const =0
 
virtual stdx::expected< void, error_type > setsockopt(native_handle_type native_handle, int level, int optname, const void *optval, socklen_t optlen) const =0
 
virtual stdx::expected< bool, error_type > native_non_blocking(native_handle_type native_handle) const =0
 
virtual stdx::expected< void, error_type > listen(native_handle_type native_handle, int backlog) const =0
 
virtual stdx::expected< void, error_type > connect(native_handle_type native_handle, const struct sockaddr *addr, size_t addr_len) const =0
 
virtual stdx::expected< void, error_type > wait(native_handle_type fd, wait_type wt) const =0
 
virtual stdx::expected< void, error_type > shutdown(native_handle_type fd, int how) const =0
 
Definition: io_context.h:1003
 
io_context & context() const noexcept
Definition: io_context.h:1015
 
Definition: io_context.h:61
 
impl::socket::SocketServiceBase * socket_service() const
Definition: io_context.h:135
 
void async_wait(native_handle_type fd, impl::socket::wait_type wt, Op &&op)
Definition: io_context.h:483
 
executor_type get_executor() noexcept
Definition: io_context.h:1093
 
stdx::expected< void, std::error_code > cancel(native_handle_type fd)
cancel all async-ops of a file-descriptor.
Definition: io_context.h:1100
 
socket option for SO_LINGER
Definition: socket.h:275
 
linger() noexcept
Definition: socket.h:277
 
int level(const Protocol &) const noexcept
Definition: socket.h:293
 
linger(bool e, std::chrono::seconds t) noexcept
Definition: socket.h:279
 
std::chrono::seconds timeout() const noexcept
Definition: socket.h:285
 
int name(const Protocol &) const noexcept
Definition: socket.h:298
 
::linger value_
Definition: socket.h:325
 
void timeout(std::chrono::seconds t) noexcept
Definition: socket.h:288
 
void resize(const Protocol &, size_t s)
Definition: socket.h:318
 
void * data(const Protocol &) noexcept
Definition: socket.h:303
 
size_t size(const Protocol &) const noexcept
Definition: socket.h:313
 
void enabled(bool e) noexcept
Definition: socket.h:283
 
const void * data(const Protocol &) const noexcept
Definition: socket.h:308
 
bool enabled() const noexcept
Definition: socket.h:282
 
void set_recipient(const endpoint_type &ep)
set recipient of the message.
Definition: socket.h:257
 
void set_sender(endpoint_type &ep)
set sender of the message.
Definition: socket.h:231
 
void resize_sender(endpoint_type &ep)
set the size of the sender after data was received.
Definition: socket.h:245
 
std::array< impl::socket::iovec_base, 16 > iov_
Definition: socket.h:195
 
msg_hdr(const BufferSequence &buffers)
Definition: socket.h:199
 
static constexpr wait_type wait_read
Definition: socket.h:168
 
static constexpr message_flags message_peek
Definition: socket.h:161
 
shutdown_type
Definition: socket.h:172
 
static constexpr shutdown_type shutdown_both
Definition: socket.h:186
 
static constexpr shutdown_type shutdown_receive
Definition: socket.h:183
 
static constexpr message_flags message_do_not_route
Definition: socket.h:164
 
static constexpr message_flags message_out_of_band
Definition: socket.h:162
 
impl::socket::message_flags message_flags
Definition: socket.h:159
 
static const int max_listen_connections
Definition: socket.h:188
 
static constexpr shutdown_type shutdown_send
Definition: socket.h:185
 
static constexpr wait_type wait_write
Definition: socket.h:169
 
static constexpr wait_type wait_error
Definition: socket.h:170
 
base-class of socket options.
Definition: socket.h:77
 
storage_type * data(const Protocol &)
Definition: socket.h:105
 
constexpr option_base()
Definition: socket.h:82
 
constexpr int name(const Protocol &) const noexcept
Definition: socket.h:95
 
storage_type value_
Definition: socket.h:122
 
constexpr int level(const Protocol &) const noexcept
Definition: socket.h:90
 
V storage_type
Definition: socket.h:80
 
T value_type
Definition: socket.h:79
 
constexpr size_t size(const Protocol &) const
Definition: socket.h:110
 
void resize(const Protocol &, size_t s)
Definition: socket.h:115
 
value_type value() const
Definition: socket.h:87
 
const storage_type * data(const Protocol &) const
Definition: socket.h:100
 
constexpr option_base(value_type v)
Definition: socket.h:84
 
Definition: expected.h:944
 
static int flags[50]
Definition: hp_test1.cc:40
 
mysql_service_status_t send(const char *tag, const unsigned char *data, const size_t data_length) noexcept
Definition: message_service.cc:32
 
Definition: authentication.cc:36
 
std::error_code make_error_code(DynamicLoaderErrc ec)
make error_code from a DynamicLoaderErrc.
Definition: dynamic_loader.cc:79
 
stdx::expected< void, error_type > listen(native_handle_type native_handle, int backlog)
Definition: socket.h:149
 
stdx::expected< native_handle_type, error_type > socket(int family, int sock_type, int protocol)
Definition: socket.h:63
 
stdx::expected< void, std::error_code > init()
Definition: socket.h:673
 
stdx::expected< void, error_type > bind(native_handle_type native_handle, const struct sockaddr *addr, size_t addr_len)
wrap bind() in a portable way.
Definition: socket.h:339
 
stdx::expected< void, error_type > native_non_blocking(native_handle_type native_handle, bool on)
Definition: socket.h:121
 
stdx::expected< native_handle_type, error_type > accept(native_handle_type native_handle, struct sockaddr *addr, socklen_t *addr_len)
wrap accept() in a portable way.
Definition: socket.h:367
 
stdx::expected< void, std::error_code > close(native_handle_type native_handle)
Definition: socket.h:75
 
wait_type
Definition: socket_constants.h:86
 
::msghdr msghdr_base
Definition: socket_constants.h:60
 
static constexpr message_flags message_out_of_band
Definition: socket_constants.h:67
 
static constexpr message_flags message_do_not_route
Definition: socket_constants.h:68
 
std::error_code error_type
Definition: socket_constants.h:55
 
std::bitset< 31 > message_flags
Definition: socket_constants.h:64
 
static constexpr message_flags message_peek
Definition: socket_constants.h:66
 
stdx::expected< void, error_type > shutdown(native_handle_type fd, int how)
Definition: socket.h:663
 
int native_handle_type
Definition: socket_constants.h:51
 
constexpr const native_handle_type kInvalidSocket
Definition: socket_constants.h:52
 
stdx::expected< void, error_type > wait(native_handle_type fd, wait_type wt)
Definition: socket.h:636
 
const const_buffer * buffer_sequence_end(const const_buffer &b) noexcept
Definition: buffer.h:185
 
auto defer(CompletionToken &&token)
Definition: executor.h:804
 
const const_buffer * buffer_sequence_begin(const const_buffer &b) noexcept
Definition: buffer.h:180
 
size_t buffer_size(const ConstBufferSequence &buffers) noexcept
Definition: buffer.h:315
 
stdx::expected< InputIterator, std::error_code > connect(basic_socket< Protocol > &s, InputIterator first, InputIterator last)
Definition: socket.h:1799
 
std::error_condition make_error_condition(net::stream_errc e) noexcept
Definition: buffer.h:107
 
std::error_code make_error_code(net::stream_errc e) noexcept
Definition: buffer.h:103
 
static int handle(int sql_errno, const char *sqlstate, const char *message, void *state)
Bridge function between the C++ API offered by this module and the C API of the parser service.
Definition: services.cc:64
 
stdx::expected< int, std::error_code > open(const char *fname, int flags, mode_t mode) noexcept
Definition: file_handle.cc:79
 
mode
Definition: file_handle.h:61
 
native_handle_type native_handle()
Definition: process.h:56
 
constexpr auto make_unexpected(E &&e) -> unexpected< std::decay_t< E > >
Definition: expected.h:125
 
struct sockaddr sockaddr
Definition: sock_probe_win32.h:63
 
case opt name
Definition: sslopt-case.h:33
 
double seconds()
Definition: task.cc:310