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;
 
  461      static_cast<char>(-1)
 
  469template <
typename Protocol>
 
  488    if (
this == std::addressof(rhs)) {
 
  508        protocol.family(), protocol.type() | 
flags, protocol.protocol());
 
  511    if ((
flags & SOCK_NONBLOCK) != 0) {
 
  516    return assign(protocol, res.value());
 
  533        reinterpret_cast<const struct 
sockaddr *
>(endpoint.data()),
 
  539                                                 socklen_t *endpoint_size,
 
  547      } 
else if (res.error() != std::errc::operation_not_supported) {
 
  557    return ret_type{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 error_code) mutable {
 
  785                  __compl_handler(error_code);
 
  790                net::socket_base::error so_error;
 
  792                auto result = get_option(so_error);
 
  794                  __compl_handler(result.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 {
 
  826    return __base::get_option(option);
 
  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  template <
typename CompletionToken>
 
  876    get_executor().context().async_wait(
 
  878        [__compl_handler = std::move(
init.completion_handler)](
 
  879            std::error_code ec) 
mutable { __compl_handler(ec); });
 
  881    return init.result.get();
 
  910template <
typename Protocol>
 
  939  template <
class MutableBufferSequence>
 
  944    return this->get_executor().context().socket_service()->recvmsg(
 
  948  template <
class MutableBufferSequence>
 
  950      const MutableBufferSequence &buffers) {
 
  951    return receive(buffers, 0);
 
  954  template <
class MutableBufferSequence>
 
  961    auto res = this->get_executor().context().socket_service()->recvmsg(
 
  972  template <
class MutableBufferSequence>
 
  974      const MutableBufferSequence &buffers, 
endpoint_type &sender) {
 
  975    return receive_from(buffers, sender, 0);
 
  978  template <
class MutableBufferSequence>
 
  980      const MutableBufferSequence &buffers) {
 
  981    return receive(buffers);
 
  984  template <
class ConstBufferSequence>
 
  991    return this->get_executor().context().socket_service()->sendmsg(
 
  995  template <
class ConstBufferSequence>
 
  997      const ConstBufferSequence &buffers) {
 
 1000    return send(buffers, 0);
 
 1003  template <
class ConstBufferSequence>
 
 1005      const ConstBufferSequence &buffers, 
const endpoint_type &recipient,
 
 1012    return this->get_executor().context().socket_service()->sendmsg(
 
 1016  template <
class ConstBufferSequence>
 
 1018      const ConstBufferSequence &buffers, 
const endpoint_type &recipient) {
 
 1021    return send_to(buffers, recipient, 0);
 
 1024  template <
class ConstBufferSequence>
 
 1026      const ConstBufferSequence &buffers) {
 
 1029    return send(buffers);
 
 1037  template <
class MutableBufferSequence, 
class CompletionToken>
 
 1040                     CompletionToken &&token) {
 
 1051      return init.result.get();
 
 1054    this->get_executor().context().async_wait(
 
 1056        [socket_service = this->get_executor().context().socket_service(),
 
 1057         compl_handler = std::move(
init.completion_handler), &buffers,
 
 1059         flags](std::error_code ec) 
mutable {
 
 1061            compl_handler(ec, 0);
 
 1069            compl_handler(res.error(), 0);
 
 1071            compl_handler({}, res.value());
 
 1075    return init.result.get();
 
 1078  template <
class MutableBufferSequence, 
class CompletionToken>
 
 1080                     CompletionToken &&token) {
 
 1084    return async_receive(buffers, 0, std::forward<CompletionToken>(token));
 
 1089template <
typename Protocol>
 
 1116  template <
class MutableBufferSequence>
 
 1123    auto res = this->get_executor().context().socket_service()->recvmsg(
 
 1126    if (res && res.value() == 0) {
 
 1134  template <
class MutableBufferSequence>
 
 1136      const MutableBufferSequence &buffers) {
 
 1137    return receive(buffers, 0);
 
 1140  template <
class MutableBufferSequence>
 
 1142      const MutableBufferSequence &buffers) {
 
 1143    return receive(buffers);
 
 1146  template <
class ConstBufferSequence>
 
 1155    auto res = this->get_executor().context().socket_service()->sendmsg(
 
 1158    if (res && res.value() == 0) {
 
 1166  template <
class ConstBufferSequence>
 
 1168      const ConstBufferSequence &buffers) {
 
 1171    return send(buffers, 0);
 
 1174  template <
class ConstBufferSequence>
 
 1176      const ConstBufferSequence &buffers) {
 
 1179    return send(buffers);
 
 1187  template <
class MutableBufferSequence, 
class CompletionToken>
 
 1190                     CompletionToken &&token) {
 
 1200      return init.result.get();
 
 1204      init.completion_handler({}, 0);
 
 1206      return init.result.get();
 
 1209    this->get_executor().context().async_wait(
 
 1211        [socket_service = this->get_executor().context().socket_service(),
 
 1212         compl_handler = std::move(
init.completion_handler), buffers,
 
 1215            compl_handler(ec, 0);
 
 1223            compl_handler(res.error(), 0);
 
 1224          } 
else if (res.value() == 0) {
 
 1228            compl_handler({}, res.value());
 
 1234    return init.result.get();
 
 1237  template <
class MutableBufferSequence, 
class CompletionToken>
 
 1239                     CompletionToken &&token) {
 
 1243    return async_receive(buffers, 0, std::forward<CompletionToken>(token));
 
 1246  template <
class ConstBufferSequence, 
class CompletionToken>
 
 1253      init.completion_handler({}, 0);
 
 1255      return init.result.get();
 
 1258    this->get_executor().context().async_wait(
 
 1260        [socket_service = this->get_executor().context().socket_service(),
 
 1261         compl_handler = std::move(
init.completion_handler), buffers,
 
 1264            compl_handler(ec, 0);
 
 1272            compl_handler(res.error(), 0);
 
 1274            compl_handler({}, res.value());
 
 1280    return init.result.get();
 
 1283  template <
class ConstBufferSequence, 
class CompletionToken>
 
 1284  auto async_send(
const ConstBufferSequence &buffers, CompletionToken &&token) {
 
 1286    return async_send(buffers, 0, std::forward<CompletionToken>(token));
 
 1291template <
typename AcceptableProtocol>
 
 1317    return __base::assign(protocol, native_acceptor);
 
 1321    return __base::release();
 
 1326  constexpr bool is_open()
 const { 
return __base::is_open(); }
 
 1332  template <
typename SettableSocketOption>
 
 1334      const SettableSocketOption &option) {
 
 1335    return __base::set_option(option);
 
 1338  template <
typename GettableSocketOption>
 
 1340      GettableSocketOption &option)
 const {
 
 1341    return __base::get_option(option);
 
 1347    return __base::non_blocking(
mode);
 
 1365    return __base::local_endpoint();
 
 1382      if (accept_res || enable_connection_aborted() ||
 
 1383          accept_res.error() !=
 
 1392    return accept(get_executor().context(), endpoint, 
flags);
 
 1402      if (accept_res || enable_connection_aborted() ||
 
 1403          accept_res.error() !=
 
 1410  template <
class CompletionToken>
 
 1418        [
this, __compl_handler = std::move(
init.completion_handler),
 
 1420         &io_ctx](std::error_code ec) 
mutable {
 
 1427            auto res = this->get_executor().context().socket_service()->accept(
 
 1428                __fd, 
nullptr, 
nullptr);
 
 1430            if (!res && !enable_connection_aborted() &&
 
 1437              __compl_handler(res.error(), 
socket_type(io_ctx));
 
 1439              __compl_handler({}, 
socket_type{io_ctx, __protocol, res.value()});
 
 1445    return init.result.get();
 
 1448  template <
class CompletionToken>
 
 1450    return async_accept(get_executor().context(), endpoint,
 
 1451                        std::forward<CompletionToken>(token));
 
 1465  template <
class CompletionToken>
 
 1467                    CompletionToken &&token) {
 
 1476        [
this, __compl_handler = std::move(
init.completion_handler),
 
 1477         __protocol = protocol_, __fd = 
native_handle(), &__ep = endpoint,
 
 1478         &io_ctx](std::error_code ec) 
mutable {
 
 1485            socklen_t endpoint_len = __ep.capacity();
 
 1487            auto res = this->get_executor().context().socket_service()->accept(
 
 1488                __fd, 
static_cast<sockaddr *
>(__ep.data()), &endpoint_len);
 
 1490            if (!res && !enable_connection_aborted() &&
 
 1497              __compl_handler(res.error(), 
socket_type(io_ctx));
 
 1499              __ep.resize(endpoint_len);
 
 1501              __compl_handler({}, 
socket_type{io_ctx, __protocol, res.value()});
 
 1507    return init.result.get();
 
 1510  template <
class CompletionToken>
 
 1512    return async_accept(get_executor().context(),
 
 1513                        std::forward<CompletionToken>(token));
 
 1520  template <
typename CompletionToken>
 
 1524    get_executor().context().async_wait(
 
 1526        [compl_handler = std::move(
init.completion_handler)](
 
 1527            std::error_code ec) 
mutable { compl_handler(ec); });
 
 1529    return init.result.get();
 
 1534  bool enable_connection_aborted_{
false};
 
 1551template <
class Protocol, 
class Endpo
intSequence, 
class ConnectCondition>
 
 1554    ConnectCondition c) {
 
 1567template <
class Protocol, 
class Endpo
intSequence>
 
 1570  return connect(s, endpoints, [](
auto, 
auto) { 
return true; });
 
 1585template <
class Protocol, 
class InputIterator, 
class ConnectCondition>
 
 1588    ConnectCondition c) {
 
 1592  for (InputIterator cur = first; cur != last; ++cur) {
 
 1594    if (!c(ec, *cur)) 
continue;
 
 1596    auto res = s.
close();
 
 1602    res = s.
open(
typename Protocol::endpoint(*cur).protocol());
 
 1619template <
class Protocol, 
class InputIterator, 
class ConnectCondition>
 
 1622  return connect(s, first, last, [](
auto, 
auto) { 
return true; });
 
 1627#if defined(MYSQL_HARNESS_HEADER_ONLY) 
 1628#include "mysql/harness/net_ts/socket.cpp" 
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:1017
 
stdx::expected< size_t, std::error_code > receive_from(const MutableBufferSequence &buffers, endpoint_type &sender)
Definition: socket.h:973
 
stdx::expected< bool, error_type > shutdown(socket_base::shutdown_type st) const
Definition: socket.h:1032
 
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:921
 
stdx::expected< size_t, std::error_code > receive(const MutableBufferSequence &buffers, socket_base::message_flags flags)
Definition: socket.h:940
 
basic_datagram_socket(io_context &ctx, const protocol_type &protocol, const native_handle_type &native_handle)
Definition: socket.h:935
 
stdx::expected< size_t, std::error_code > receive_from(const MutableBufferSequence &buffers, endpoint_type &sender, socket_base::message_flags flags)
Definition: socket.h:955
 
basic_datagram_socket(basic_datagram_socket &&other)=default
 
stdx::expected< size_t, std::error_code > receive(const MutableBufferSequence &buffers)
Definition: socket.h:949
 
stdx::expected< size_t, std::error_code > send(const ConstBufferSequence &buffers, socket_base::message_flags flags)
Definition: socket.h:985
 
auto async_receive(const MutableBufferSequence &buffers, socket_base::message_flags flags, CompletionToken &&token)
Definition: socket.h:1038
 
basic_datagram_socket & operator=(basic_datagram_socket &&)=default
 
stdx::expected< size_t, std::error_code > read_some(const MutableBufferSequence &buffers)
Definition: socket.h:979
 
stdx::expected< size_t, std::error_code > send(const ConstBufferSequence &buffers)
Definition: socket.h:996
 
basic_datagram_socket(io_context &ctx)
Definition: socket.h:920
 
stdx::expected< size_t, std::error_code > send_to(const ConstBufferSequence &buffers, const endpoint_type &recipient, socket_base::message_flags flags)
Definition: socket.h:1004
 
~basic_datagram_socket()=default
 
stdx::expected< size_t, std::error_code > write_some(const ConstBufferSequence &buffers)
Definition: socket.h:1025
 
auto async_receive(const MutableBufferSequence &buffers, CompletionToken &&token)
Definition: socket.h:1079
 
Definition: socket.h:1293
 
basic_socket_acceptor(io_context &ctx)
Definition: socket.h:1304
 
typename protocol_type::endpoint endpoint_type
Definition: socket.h:1301
 
auto async_accept(io_context &io_ctx, endpoint_type &endpoint, CompletionToken &&token)
accept a connection with endpoint async'.
Definition: socket.h:1466
 
std::error_code error_type
Definition: socket.h:1302
 
stdx::expected< endpoint_type, error_type > local_endpoint() const
Definition: socket.h:1364
 
bool native_non_blocking() const
Definition: socket.h:1350
 
bool non_blocking() const
Definition: socket.h:1344
 
stdx::expected< void, error_type > assign(const protocol_type &protocol, const native_handle_type &native_acceptor)
Definition: socket.h:1314
 
stdx::expected< native_handle_type, error_type > release()
Definition: socket.h:1320
 
stdx::expected< socket_type, error_type > accept(int flags=0)
Definition: socket.h:1372
 
native_handle_type native_handle() const
Definition: socket.h:1324
 
stdx::expected< void, error_type > listen(int backlog)
Definition: socket.h:1360
 
stdx::expected< void, error_type > open(const protocol_type &protocol=protocol_type(), int flags=0)
Definition: socket.h:1309
 
AcceptableProtocol protocol_type
Definition: socket.h:1299
 
stdx::expected< socket_type, error_type > accept(endpoint_type &endpoint, int flags=0)
Definition: socket.h:1390
 
typename protocol_type::socket socket_type
Definition: socket.h:1300
 
stdx::expected< void, error_type > bind(const endpoint_type &endpoint)
Definition: socket.h:1356
 
stdx::expected< socket_type, error_type > accept(io_context &io_ctx, endpoint_type &endpoint, int flags=0)
Definition: socket.h:1395
 
stdx::expected< void, error_type > close()
Definition: socket.h:1328
 
auto async_accept(endpoint_type &endpoint, CompletionToken &&token)
Definition: socket.h:1449
 
executor_type get_executor() noexcept
Definition: socket.h:1307
 
protocol_type protocol_
Definition: socket.h:1533
 
stdx::expected< void, std::error_code > wait(socket_base::wait_type wt)
Definition: socket.h:1516
 
auto async_accept(CompletionToken &&token)
Definition: socket.h:1511
 
stdx::expected< void, error_type > cancel()
Definition: socket.h:1330
 
bool enable_connection_aborted() const
Definition: socket.h:1370
 
stdx::expected< void, std::error_code > native_non_blocking(bool mode)
Definition: socket.h:1352
 
auto async_accept(io_context &io_ctx, CompletionToken &&token)
Definition: socket.h:1411
 
stdx::expected< void, error_type > get_option(GettableSocketOption &option) const
Definition: socket.h:1339
 
auto async_wait(wait_type w, CompletionToken &&token)
Definition: socket.h:1521
 
stdx::expected< void, std::error_code > non_blocking(bool mode)
Definition: socket.h:1346
 
constexpr bool is_open() const
Definition: socket.h:1326
 
stdx::expected< socket_type, error_type > accept(io_context &io_ctx, int flags=0)
Definition: socket.h:1376
 
stdx::expected< void, error_type > set_option(const SettableSocketOption &option)
Definition: socket.h:1333
 
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:465
 
basic_socket_impl_base & operator=(const basic_socket_impl_base &rhs)=delete
 
bool non_blocking_
Definition: socket.h:451
 
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:441
 
stdx::expected< void, std::error_code > cancel()
Definition: socket.h:432
 
native_handle_type native_handle_
Definition: socket.h:449
 
stdx::expected< void, std::error_code > close()
Definition: socket.h:416
 
char native_non_blocking_
Definition: socket.h:452
 
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:478
 
basic_socket_impl(basic_socket_impl &&rhs)=default
 
Protocol protocol_type
Definition: socket.h:475
 
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:530
 
stdx::expected< socket_type, error_type > accept(io_context &io_ctx, int flags=0)
Definition: socket.h:560
 
~basic_socket_impl()
Definition: socket.h:498
 
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:502
 
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:476
 
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:519
 
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:480
 
protocol_type protocol_
Definition: socket.h:707
 
std::error_code error_type
Definition: socket.h:477
 
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:487
 
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:537
 
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
 
auto async_wait(wait_type w, CompletionToken &&token)
Definition: socket.h:873
 
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:887
 
basic_socket(io_context &ctx, const protocol_type &proto, const native_handle_type &native_handle)
Definition: socket.h:890
 
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:885
 
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:1090
 
stdx::expected< size_t, std::error_code > send(const ConstBufferSequence &buffers)
Definition: socket.h:1167
 
stdx::expected< size_t, std::error_code > read_some(const MutableBufferSequence &buffers)
Definition: socket.h:1141
 
stdx::expected< void, error_type > shutdown(socket_base::shutdown_type st) const
Definition: socket.h:1182
 
stdx::expected< size_t, std::error_code > receive(const MutableBufferSequence &buffers)
Definition: socket.h:1135
 
basic_stream_socket(const basic_stream_socket &)=delete
 
auto async_send(const ConstBufferSequence &buffers, CompletionToken &&token)
Definition: socket.h:1284
 
auto async_receive(const MutableBufferSequence &buffers, CompletionToken &&token)
Definition: socket.h:1238
 
stdx::expected< size_t, std::error_code > write_some(const ConstBufferSequence &buffers)
Definition: socket.h:1175
 
basic_stream_socket(io_context &ctx, const protocol_type &protocol, const native_handle_type &native_handle)
Definition: socket.h:1112
 
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:1117
 
auto async_send(const ConstBufferSequence &buffers, socket_base::message_flags flags, CompletionToken &&token)
Definition: socket.h:1247
 
stdx::expected< size_t, std::error_code > send(const ConstBufferSequence &buffers, socket_base::message_flags flags)
Definition: socket.h:1147
 
basic_stream_socket(io_context &ctx)
Definition: socket.h:1099
 
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:1188
 
basic_stream_socket & operator=(const basic_stream_socket &)=delete
 
basic_stream_socket(io_context &ctx, const protocol_type &proto)
Definition: socket.h:1100
 
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:1004
 
io_context & context() const noexcept
Definition: io_context.h:1016
 
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:1094
 
stdx::expected< void, std::error_code > cancel(native_handle_type fd)
cancel all async-ops of a file-descriptor.
Definition: io_context.h:1101
 
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:286
 
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:33
 
Definition: http_server_component.cc:34
 
std::error_code make_error_code(DynamicLoaderErrc ec)
make error_code from a DynamicLoaderErrc.
Definition: dynamic_loader.cc:79
 
const char * begin(const char *const c)
Definition: base64.h:44
 
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:669
 
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:659
 
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:632
 
const const_buffer * buffer_sequence_end(const const_buffer &b) noexcept
Definition: buffer.h:185
 
auto defer(CompletionToken &&token)
Definition: executor.h:779
 
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:313
 
stdx::expected< InputIterator, std::error_code > connect(basic_socket< Protocol > &s, InputIterator first, InputIterator last)
Definition: socket.h:1620
 
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
 
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
 
unexpected(E) -> unexpected< E >
 
struct sockaddr sockaddr
Definition: sock_probe_win32.h:63
 
case opt name
Definition: sslopt-case.h:29
 
double seconds()
Definition: task.cc:314