restinio::impl::acceptor_t< Traits > Class Template Referencefinal

Context for accepting http connections. More...

`#include <acceptor.hpp>`

Inheritance diagram for restinio::impl::acceptor_t< Traits >:

## Public Types

using | connection_factory_t = impl::connection_factory_t< Traits >
using | connection_factory_shared_ptr_t = std::shared_ptr< connection_factory_t >
using | logger_t = typename Traits::logger_t
using | strand_t = typename Traits::strand_t
using | stream_socket_t = typename Traits::stream_socket_t
using | socket_holder_base_t = socket_supplier_t< stream_socket_t >

## Public Member Functions

template<typename Settings >
| acceptor_t (Settings &settings, asio_ns::io_context &io_context, connection_factory_shared_ptr_t connection_factory, logger_t &logger)
void | open ()
| Start listen on port specified in ctor. More...
void | close ()
| Close listener if any. More...
auto & | get_open_close_operations_executor () noexcept
| Get an executor for close operation. More...

## Private Types

using | ip_blocker_base_t = acceptor_details::ip_blocker_holder_t< typename Traits::ip_blocker_t >
using | connection_count_limiter_t = typename connection_count_limit_types< Traits >::limiter_t
using | connection_lifetime_monitor_t = typename connection_count_limit_types< Traits >::lifetime_monitor_t

## Private Member Functions

auto & | get_executor () noexcept
| Get executor for acceptor. More...
void | call_accept_now (std::size_t index) noexcept
void | schedule_next_accept_attempt (std::size_t index) noexcept
::restinio::connection_count_limits::impl::acceptor_callback_iface_t * | self_as_acceptor_callback () noexcept
| Helper for suppressing warnings of using `this` in initilizer list. More...
void | accept_next (std::size_t i) noexcept
| Set a callback for a new connection. More...
void | accept_current_connection (std::size_t i, const std::error_code &ec) noexcept
| Accept current connection. More...
void | accept_connection_for_socket_with_index (std::size_t i)
| Performs actual actions for accepting a new connection. More...
void | do_accept_current_connection (stream_socket_t incoming_socket, endpoint_t remote_endpoint)
void | close_impl ()
| Close opened acceptor. More...

## Static Private Member Functions

static RESTINIO_NODISCARD optional_t< asio_ns::ip::address > | try_extract_actual_address_from_variant (const restinio::details::address_variant_t &from)
| Helper for extraction of an actual IP-address from an instance of address_variant. More...

## Private Attributes

default_asio_executor | m_executor
| Asio executor. More...
strand_t | m_open_close_operations_executor
const bool | m_separate_accept_and_create_connect
| Do separate an accept operation and connection instantiation. More...
connection_factory_shared_ptr_t | m_connection_factory
| Factory for creating connections. More...
logger_t & | m_logger
connection_count_limiter_t | m_connection_count_limiter
| Actual limiter of active parallel connections. More...
const std::uint16_t | m_port
| Server endpoint. More...
const asio_ns::ip::tcp | m_protocol
const restinio::details::address_variant_t | m_address
std::unique_ptr< acceptor_options_setter_t > | m_acceptor_options_setter
| Server port listener and connection receiver routine. More...
asio_ns::ip::tcp::acceptor | m_acceptor
acceptor_post_bind_hook_t | m_acceptor_post_bind_hook
| A hook to be called just after a successful call to bind for acceptor. More...

## Additional Inherited Members

Protected Member Functions inherited from restinio::impl::socket_supplier_t< Traits::stream_socket_t >
| socket_supplier_t (Settings &settings, asio_ns::io_context &io_context)
Traits::stream_socket_t & | socket (std::size_t idx)
| Get the reference to socket. More...
Traits::stream_socket_t | move_socket (std::size_t idx)
| Extract the socket via move. More...
auto | concurrent_accept_sockets_count () const noexcept
| The number of sockets that can be used for cuncurrent accept operations. More...
Protected Member Functions inherited from restinio::impl::acceptor_details::ip_blocker_holder_t< Ip_Blocker >
template<typename Settings >
| ip_blocker_holder_t (const Settings &settings)
template<typename Socket >
restinio::ip_blocker::inspection_result_t | inspect_incoming (Socket &socket) const noexcept
virtual void | call_accept_now (std::size_t index) noexcept=0
virtual void | schedule_next_accept_attempt (std::size_t index) noexcept=0
Protected Attributes inherited from restinio::impl::acceptor_details::ip_blocker_holder_t< Ip_Blocker >
std::shared_ptr< Ip_Blocker > | m_ip_blocker

## Detailed Description

template<typename Traits>
class restinio::impl::acceptor_t< Traits >

Context for accepting http connections.

Definition at line 162 of file acceptor.hpp.

## Member Typedef Documentation

## connection_count_limiter_t

template<typename Traits >

using restinio::impl::acceptor_t< Traits >::connection_count_limiter_t = typename connection_count_limit_types< Traits >::limiter_t

private

Definition at line 171 of file acceptor.hpp.

## connection_factory_shared_ptr_t

template<typename Traits >

using restinio::impl::acceptor_t< Traits >::connection_factory_shared_ptr_t = std::shared_ptr< connection_factory_t >

Definition at line 178 of file acceptor.hpp.

## connection_factory_t

template<typename Traits >

using restinio::impl::acceptor_t< Traits >::connection_factory_t = impl::connection_factory_t< Traits >

Definition at line 177 of file acceptor.hpp.

## connection_lifetime_monitor_t

template<typename Traits >

using restinio::impl::acceptor_t< Traits >::connection_lifetime_monitor_t = typename connection_count_limit_types< Traits >::lifetime_monitor_t

private

Definition at line 173 of file acceptor.hpp.

## ip_blocker_base_t

template<typename Traits >

using restinio::impl::acceptor_t< Traits >::ip_blocker_base_t = acceptor_details::ip_blocker_holder_t< typename Traits::ip_blocker_t >

private

Definition at line 168 of file acceptor.hpp.

## logger_t

template<typename Traits >

using restinio::impl::acceptor_t< Traits >::logger_t = typename Traits::logger_t

Definition at line 180 of file acceptor.hpp.

## socket_holder_base_t

template<typename Traits >

using restinio::impl::acceptor_t< Traits >::socket_holder_base_t = socket_supplier_t< stream_socket_t >

Definition at line 183 of file acceptor.hpp.

## strand_t

template<typename Traits >

using restinio::impl::acceptor_t< Traits >::strand_t = typename Traits::strand_t

Definition at line 181 of file acceptor.hpp.

## stream_socket_t

template<typename Traits >

using restinio::impl::acceptor_t< Traits >::stream_socket_t = typename Traits::stream_socket_t

Definition at line 182 of file acceptor.hpp.

## Constructor & Destructor Documentation

## acceptor_t()

template<typename Traits >
template<typename Settings >

restinio::impl::acceptor_t< Traits >::acceptor_t | ( | Settings & | settings,
|  | asio_ns::io_context & | io_context,
|  | connection_factory_shared_ptr_t | connection_factory,
|  | logger_t & | logger
| ) |  |

inline

Parameters

  io_context | ASIO io_context to run on.
  connection_factory | Connection factory.
  logger | Logger.

Definition at line 186 of file acceptor.hpp.

## Member Function Documentation

## accept_connection_for_socket_with_index()

template<typename Traits >

void restinio::impl::acceptor_t< Traits >::accept_connection_for_socket_with_index | ( | std::size_t | i | ) |

inlineprivate

Performs actual actions for accepting a new connection.

Note
  This method can throw. An we expect that it can throw sometimes.

Since
  v.0.6.0

Parameters

  i | socket index in the pool of sockets.

Definition at line 431 of file acceptor.hpp.

## accept_current_connection()

template<typename Traits >

void restinio::impl::acceptor_t< Traits >::accept_current_connection | ( | std::size_t | i,
|  | const std::error_code & | ec
| ) |  |

inlineprivatenoexcept

Accept current connection.

Note
  This method is marked as noexcept in v.0.6.0.

Parameters

  i | socket index in the pool of sockets.

Definition at line 392 of file acceptor.hpp.

## accept_next()

template<typename Traits >

void restinio::impl::acceptor_t< Traits >::accept_next | ( | std::size_t | i | ) |

inlineprivatenoexcept

Set a callback for a new connection.

Note
  This method is marked as noexcept in v.0.6.0. It seems that nothing prevents exceptions from a call to async_accept. But we just don't know what to do in that case. So at the moment the call to `std::terminate` because an exception is raised inside `noexcept` method seems to be an appropriate solution.

Definition at line 381 of file acceptor.hpp.

## call_accept_now()

template<typename Traits >

void restinio::impl::acceptor_t< Traits >::call_accept_now | ( | std::size_t | index | ) |

inlineprivatevirtualnoexcept

Since
  v.0.6.12

Implements restinio::connection_count_limits::impl::acceptor_callback_iface_t.

Definition at line 326 of file acceptor.hpp.

## close()

template<typename Traits >

void restinio::impl::acceptor_t< Traits >::close | ( |  | ) |

inline

Close listener if any.

Definition at line 296 of file acceptor.hpp.

## close_impl()

template<typename Traits >

void restinio::impl::acceptor_t< Traits >::close_impl | ( |  | ) |

inlineprivate

Close opened acceptor.

Definition at line 521 of file acceptor.hpp.

## do_accept_current_connection()

template<typename Traits >

void restinio::impl::acceptor_t< Traits >::do_accept_current_connection | ( | stream_socket_t | incoming_socket,
|  | endpoint_t | remote_endpoint
| ) |  |

inlineprivate

Definition at line 474 of file acceptor.hpp.

## get_executor()

template<typename Traits >

auto & restinio::impl::acceptor_t< Traits >::get_executor | ( |  | ) |

inlineprivatenoexcept

Get executor for acceptor.

Definition at line 319 of file acceptor.hpp.

## get_open_close_operations_executor()

template<typename Traits >

auto & restinio::impl::acceptor_t< Traits >::get_open_close_operations_executor | ( |  | ) |

inlinenoexcept

Get an executor for close operation.

Definition at line 312 of file acceptor.hpp.

## open()

template<typename Traits >

void restinio::impl::acceptor_t< Traits >::open | ( |  | ) |

inline

Start listen on port specified in ctor.

Definition at line 220 of file acceptor.hpp.

## schedule_next_accept_attempt()

template<typename Traits >

void restinio::impl::acceptor_t< Traits >::schedule_next_accept_attempt | ( | std::size_t | index | ) |

inlineprivatevirtualnoexcept

Since
  v.0.6.12

Implements restinio::connection_count_limits::impl::acceptor_callback_iface_t.

Definition at line 346 of file acceptor.hpp.

## self_as_acceptor_callback()

template<typename Traits >

::restinio::connection_count_limits::impl::acceptor_callback_iface_t * restinio::impl::acceptor_t< Traits >::self_as_acceptor_callback | ( |  | ) |

inlineprivatenoexcept

Helper for suppressing warnings of using `this` in initilizer list.

Since
  v.0.6.12

Definition at line 364 of file acceptor.hpp.

## try_extract_actual_address_from_variant()

template<typename Traits >

static RESTINIO_NODISCARD optional_t< asio_ns::ip::address > restinio::impl::acceptor_t< Traits >::try_extract_actual_address_from_variant | ( | const restinio::details::address_variant_t & | from | ) |

inlinestaticprivate

Helper for extraction of an actual IP-address from an instance of address_variant.

Returns an empty value if there is no address inside from.

Since
  v.0.6.11

Definition at line 587 of file acceptor.hpp.

## Member Data Documentation

## m_acceptor

template<typename Traits >

asio_ns::ip::tcp::acceptor restinio::impl::acceptor_t< Traits >::m_acceptor

private

Definition at line 549 of file acceptor.hpp.

## m_acceptor_options_setter

template<typename Traits >

std::unique_ptr< acceptor_options_setter_t > restinio::impl::acceptor_t< Traits >::m_acceptor_options_setter

private

Server port listener and connection receiver routine.

Definition at line 548 of file acceptor.hpp.

## m_acceptor_post_bind_hook

template<typename Traits >

acceptor_post_bind_hook_t restinio::impl::acceptor_t< Traits >::m_acceptor_post_bind_hook

private

A hook to be called just after a successful call to bind for acceptor.

Since
  v.0.6.11

Definition at line 555 of file acceptor.hpp.

## m_address

template<typename Traits >

const restinio::details::address_variant_t restinio::impl::acceptor_t< Traits >::m_address

private

Definition at line 543 of file acceptor.hpp.

## m_connection_count_limiter

template<typename Traits >

connection_count_limiter_t restinio::impl::acceptor_t< Traits >::m_connection_count_limiter

private

Actual limiter of active parallel connections.

Since
  v.0.6.12

Definition at line 575 of file acceptor.hpp.

## m_connection_factory

template<typename Traits >

connection_factory_shared_ptr_t restinio::impl::acceptor_t< Traits >::m_connection_factory

private

Factory for creating connections.

Definition at line 566 of file acceptor.hpp.

## m_executor

template<typename Traits >

default_asio_executor restinio::impl::acceptor_t< Traits >::m_executor

private

Asio executor.

Definition at line 559 of file acceptor.hpp.

## m_logger

template<typename Traits >

logger_t& restinio::impl::acceptor_t< Traits >::m_logger

private

Definition at line 568 of file acceptor.hpp.

## m_open_close_operations_executor

template<typename Traits >

strand_t restinio::impl::acceptor_t< Traits >::m_open_close_operations_executor

private

Definition at line 560 of file acceptor.hpp.

## m_port

template<typename Traits >

const std::uint16_t restinio::impl::acceptor_t< Traits >::m_port

private

Server endpoint.

Definition at line 541 of file acceptor.hpp.

## m_protocol

template<typename Traits >

const asio_ns::ip::tcp restinio::impl::acceptor_t< Traits >::m_protocol

private

Definition at line 542 of file acceptor.hpp.

## m_separate_accept_and_create_connect

template<typename Traits >

const bool restinio::impl::acceptor_t< Traits >::m_separate_accept_and_create_connect

private

Do separate an accept operation and connection instantiation.

Definition at line 563 of file acceptor.hpp.

The documentation for this class was generated from the following file:

- restinio/impl/acceptor.hpp