LCOV - code coverage report
Current view: top level - corosio/detail - acceptor_service.hpp (source / functions) Coverage Total Hit Missed
Test: coverage_remapped.info Lines: 100.0 % 2 2
Test Date: 2026-02-25 01:27:20 Functions: 66.7 % 3 2 1

           TLA  Line data    Source code
       1                 : //
       2                 : // Copyright (c) 2026 Steve Gerbino
       3                 : //
       4                 : // Distributed under the Boost Software License, Version 1.0. (See accompanying
       5                 : // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
       6                 : //
       7                 : // Official repository: https://github.com/cppalliance/corosio
       8                 : //
       9                 : 
      10                 : #ifndef BOOST_COROSIO_DETAIL_ACCEPTOR_SERVICE_HPP
      11                 : #define BOOST_COROSIO_DETAIL_ACCEPTOR_SERVICE_HPP
      12                 : 
      13                 : #include <boost/corosio/detail/config.hpp>
      14                 : #include <boost/corosio/tcp_acceptor.hpp>
      15                 : #include <boost/corosio/endpoint.hpp>
      16                 : #include <boost/capy/ex/execution_context.hpp>
      17                 : #include <system_error>
      18                 : 
      19                 : namespace boost::corosio::detail {
      20                 : 
      21                 : /** Abstract acceptor service base class.
      22                 : 
      23                 :     Concrete implementations ( epoll_acceptors, select_acceptors, etc. )
      24                 :     inherit from this class and provide platform-specific acceptor
      25                 :     operations. The context constructor installs whichever backend
      26                 :     via `make_service`, and `tcp_acceptor.cpp` retrieves it via
      27                 :     `use_service<acceptor_service>()`.
      28                 : */
      29                 : class BOOST_COROSIO_DECL acceptor_service
      30                 :     : public capy::execution_context::service
      31                 :     , public io_object::io_service
      32                 : {
      33                 : public:
      34                 :     /// Identifies this service for `execution_context` lookup.
      35                 :     using key_type = acceptor_service;
      36                 : 
      37                 :     /** Create the acceptor socket without binding or listening.
      38                 : 
      39                 :         Creates a socket with dual-stack enabled for IPv6 but does
      40                 :         not bind or listen. Does not set SO_REUSEADDR.
      41                 : 
      42                 :         @param impl The acceptor implementation to open.
      43                 :         @param family Address family (e.g. `AF_INET`, `AF_INET6`).
      44                 :         @param type Socket type (e.g. `SOCK_STREAM`).
      45                 :         @param protocol Protocol number (e.g. `IPPROTO_TCP`).
      46                 :         @return Error code on failure, empty on success.
      47                 :     */
      48                 :     virtual std::error_code open_acceptor_socket(
      49                 :         tcp_acceptor::implementation& impl,
      50                 :         int family, int type, int protocol) = 0;
      51                 : 
      52                 :     /** Bind an open acceptor to a local endpoint.
      53                 : 
      54                 :         @param impl The acceptor implementation to bind.
      55                 :         @param ep The local endpoint to bind to.
      56                 :         @return Error code on failure, empty on success.
      57                 :     */
      58                 :     virtual std::error_code bind_acceptor(
      59                 :         tcp_acceptor::implementation& impl, endpoint ep) = 0;
      60                 : 
      61                 :     /** Start listening for incoming connections.
      62                 : 
      63                 :         Registers the acceptor with the platform reactor after
      64                 :         calling `::listen()`.
      65                 : 
      66                 :         @param impl The acceptor implementation to listen on.
      67                 :         @param backlog The maximum length of the pending connection queue.
      68                 :         @return Error code on failure, empty on success.
      69                 :     */
      70                 :     virtual std::error_code listen_acceptor(
      71                 :         tcp_acceptor::implementation& impl, int backlog) = 0;
      72                 : 
      73                 : protected:
      74                 :     /// Construct the acceptor service.
      75 HIT         378 :     acceptor_service() = default;
      76                 : 
      77                 :     /// Destroy the acceptor service.
      78             378 :     ~acceptor_service() override = default;
      79                 : };
      80                 : 
      81                 : } // namespace boost::corosio::detail
      82                 : 
      83                 : #endif // BOOST_COROSIO_DETAIL_ACCEPTOR_SERVICE_HPP
        

Generated by: LCOV version 2.3