include/boost/corosio/native/detail/native_socket_base.hpp
97.3% Lines (36/37)
93.1% List of functions (54/58)
37.2% Branches (58/156)
Functions (58)
Function
Calls
Lines
Branches
Blocks
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_local_datagram_socket, boost::corosio::local_datagram_socket::implementation, boost::corosio::local_endpoint>::native_socket_base()
:63
92x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_local_stream_socket, boost::corosio::local_stream_socket::implementation, boost::corosio::local_endpoint>::native_socket_base()
:63
85x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_tcp_socket, boost::corosio::tcp_socket::implementation, boost::corosio::endpoint>::native_socket_base()
:63
14370x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_udp_socket, boost::corosio::udp_socket::implementation, boost::corosio::endpoint>::native_socket_base()
:63
104x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_local_datagram_socket, boost::corosio::local_datagram_socket::implementation, boost::corosio::local_endpoint>::native_socket_base()
:63
92x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_local_stream_socket, boost::corosio::local_stream_socket::implementation, boost::corosio::local_endpoint>::native_socket_base()
:63
85x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_tcp_socket, boost::corosio::tcp_socket::implementation, boost::corosio::endpoint>::native_socket_base()
:63
5668x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_udp_socket, boost::corosio::udp_socket::implementation, boost::corosio::endpoint>::native_socket_base()
:63
104x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_local_datagram_socket, boost::corosio::local_datagram_socket::implementation, boost::corosio::local_endpoint>::~native_socket_base()
:71
92x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_local_stream_socket, boost::corosio::local_stream_socket::implementation, boost::corosio::local_endpoint>::~native_socket_base()
:71
85x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_tcp_socket, boost::corosio::tcp_socket::implementation, boost::corosio::endpoint>::~native_socket_base()
:71
14370x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_udp_socket, boost::corosio::udp_socket::implementation, boost::corosio::endpoint>::~native_socket_base()
:71
104x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_local_datagram_socket, boost::corosio::local_datagram_socket::implementation, boost::corosio::local_endpoint>::~native_socket_base()
:71
92x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_local_stream_socket, boost::corosio::local_stream_socket::implementation, boost::corosio::local_endpoint>::~native_socket_base()
:71
85x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_tcp_socket, boost::corosio::tcp_socket::implementation, boost::corosio::endpoint>::~native_socket_base()
:71
5668x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_udp_socket, boost::corosio::udp_socket::implementation, boost::corosio::endpoint>::~native_socket_base()
:71
104x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_local_datagram_socket, boost::corosio::local_datagram_socket::implementation, boost::corosio::local_endpoint>::native_handle() const
:74
361x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_local_stream_socket, boost::corosio::local_stream_socket::implementation, boost::corosio::local_endpoint>::native_handle() const
:74
237x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_tcp_socket, boost::corosio::tcp_socket::implementation, boost::corosio::endpoint>::native_handle() const
:74
45952x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_udp_socket, boost::corosio::udp_socket::implementation, boost::corosio::endpoint>::native_handle() const
:74
505x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_local_datagram_socket, boost::corosio::local_datagram_socket::implementation, boost::corosio::local_endpoint>::native_handle() const
:74
361x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_local_stream_socket, boost::corosio::local_stream_socket::implementation, boost::corosio::local_endpoint>::native_handle() const
:74
237x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_tcp_socket, boost::corosio::tcp_socket::implementation, boost::corosio::endpoint>::native_handle() const
:74
17173x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_udp_socket, boost::corosio::udp_socket::implementation, boost::corosio::endpoint>::native_handle() const
:74
505x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_local_datagram_socket, boost::corosio::local_datagram_socket::implementation, boost::corosio::local_endpoint>::local_endpoint() const
:80
1x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_local_stream_socket, boost::corosio::local_stream_socket::implementation, boost::corosio::local_endpoint>::local_endpoint() const
:80
2x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_tcp_socket, boost::corosio::tcp_socket::implementation, boost::corosio::endpoint>::local_endpoint() const
:80
26x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_udp_socket, boost::corosio::udp_socket::implementation, boost::corosio::endpoint>::local_endpoint() const
:80
31x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_local_datagram_socket, boost::corosio::local_datagram_socket::implementation, boost::corosio::local_endpoint>::local_endpoint() const
:80
1x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_local_stream_socket, boost::corosio::local_stream_socket::implementation, boost::corosio::local_endpoint>::local_endpoint() const
:80
2x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_tcp_socket, boost::corosio::tcp_socket::implementation, boost::corosio::endpoint>::local_endpoint() const
:80
26x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_udp_socket, boost::corosio::udp_socket::implementation, boost::corosio::endpoint>::local_endpoint() const
:80
31x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_local_datagram_socket, boost::corosio::local_datagram_socket::implementation, boost::corosio::local_endpoint>::set_option(int, int, void const*, unsigned long)
:92
10x
100.0%
25.0%
57.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_local_stream_socket, boost::corosio::local_stream_socket::implementation, boost::corosio::local_endpoint>::set_option(int, int, void const*, unsigned long)
:92
0
100.0%
–
0.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_tcp_socket, boost::corosio::tcp_socket::implementation, boost::corosio::endpoint>::set_option(int, int, void const*, unsigned long)
:92
0
100.0%
–
0.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_udp_socket, boost::corosio::udp_socket::implementation, boost::corosio::endpoint>::set_option(int, int, void const*, unsigned long)
:92
40x
100.0%
–
85.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_local_datagram_socket, boost::corosio::local_datagram_socket::implementation, boost::corosio::local_endpoint>::set_option(int, int, void const*, unsigned long)
:92
10x
100.0%
–
57.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_local_stream_socket, boost::corosio::local_stream_socket::implementation, boost::corosio::local_endpoint>::set_option(int, int, void const*, unsigned long)
:92
0
0.0%
0.0%
0.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_tcp_socket, boost::corosio::tcp_socket::implementation, boost::corosio::endpoint>::set_option(int, int, void const*, unsigned long)
:92
0
0.0%
0.0%
0.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_udp_socket, boost::corosio::udp_socket::implementation, boost::corosio::endpoint>::set_option(int, int, void const*, unsigned long)
:92
40x
100.0%
–
85.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_local_datagram_socket, boost::corosio::local_datagram_socket::implementation, boost::corosio::local_endpoint>::get_option(int, int, void*, unsigned long*) const
:103
2x
85.7%
16.7%
57.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_local_stream_socket, boost::corosio::local_stream_socket::implementation, boost::corosio::local_endpoint>::get_option(int, int, void*, unsigned long*) const
:103
2x
100.0%
–
57.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_tcp_socket, boost::corosio::tcp_socket::implementation, boost::corosio::endpoint>::get_option(int, int, void*, unsigned long*) const
:103
40x
100.0%
–
57.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_udp_socket, boost::corosio::udp_socket::implementation, boost::corosio::endpoint>::get_option(int, int, void*, unsigned long*) const
:103
22x
100.0%
–
57.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_local_datagram_socket, boost::corosio::local_datagram_socket::implementation, boost::corosio::local_endpoint>::get_option(int, int, void*, unsigned long*) const
:103
2x
100.0%
–
57.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_local_stream_socket, boost::corosio::local_stream_socket::implementation, boost::corosio::local_endpoint>::get_option(int, int, void*, unsigned long*) const
:103
2x
85.7%
33.3%
57.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_tcp_socket, boost::corosio::tcp_socket::implementation, boost::corosio::endpoint>::get_option(int, int, void*, unsigned long*) const
:103
40x
85.7%
33.3%
57.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_udp_socket, boost::corosio::udp_socket::implementation, boost::corosio::endpoint>::get_option(int, int, void*, unsigned long*) const
:103
22x
100.0%
–
57.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_local_stream_socket, boost::corosio::local_stream_socket::implementation, boost::corosio::local_endpoint>::set_socket(int)
:115
9x
0.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_tcp_socket, boost::corosio::tcp_socket::implementation, boost::corosio::endpoint>::set_socket(int)
:115
4738x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_local_stream_socket, boost::corosio::local_stream_socket::implementation, boost::corosio::local_endpoint>::set_socket(int)
:115
9x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_tcp_socket, boost::corosio::tcp_socket::implementation, boost::corosio::endpoint>::set_socket(int)
:115
1854x
100.0%
–
100.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_local_datagram_socket, boost::corosio::local_datagram_socket::implementation, boost::corosio::local_endpoint>::do_bind(boost::corosio::local_endpoint const&)
:134
23x
100.0%
60.0%
90.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_tcp_socket, boost::corosio::tcp_socket::implementation, boost::corosio::endpoint>::do_bind(boost::corosio::endpoint const&)
:134
7x
100.0%
–
90.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::kqueue_udp_socket, boost::corosio::udp_socket::implementation, boost::corosio::endpoint>::do_bind(boost::corosio::endpoint const&)
:134
55x
100.0%
–
90.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_local_datagram_socket, boost::corosio::local_datagram_socket::implementation, boost::corosio::local_endpoint>::do_bind(boost::corosio::local_endpoint const&)
:134
23x
100.0%
–
90.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_tcp_socket, boost::corosio::tcp_socket::implementation, boost::corosio::endpoint>::do_bind(boost::corosio::endpoint const&)
:134
7x
100.0%
–
90.0%
boost::corosio::detail::native_socket_base<boost::corosio::detail::select_udp_socket, boost::corosio::udp_socket::implementation, boost::corosio::endpoint>::do_bind(boost::corosio::endpoint const&)
:134
55x
100.0%
–
90.0%
| Line | Branch | TLA | Hits | Source Code |
|---|---|---|---|---|
| 1 | // | |||
| 2 | // Copyright (c) 2026 Michael Vandeberg | |||
| 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_NATIVE_DETAIL_NATIVE_SOCKET_BASE_HPP | |||
| 11 | #define BOOST_COROSIO_NATIVE_DETAIL_NATIVE_SOCKET_BASE_HPP | |||
| 12 | ||||
| 13 | #include <boost/corosio/detail/native_handle.hpp> | |||
| 14 | #include <boost/corosio/endpoint.hpp> | |||
| 15 | #include <boost/corosio/native/detail/endpoint_convert.hpp> | |||
| 16 | #include <boost/corosio/native/detail/make_err.hpp> | |||
| 17 | ||||
| 18 | #include <memory> | |||
| 19 | #include <system_error> | |||
| 20 | ||||
| 21 | #include <errno.h> | |||
| 22 | #include <sys/socket.h> | |||
| 23 | ||||
| 24 | /* | |||
| 25 | Readiness/completion-agnostic socket base for the POSIX-fd backends. | |||
| 26 | ||||
| 27 | Holds the part of a socket impl that does not care whether the backend | |||
| 28 | is readiness-based (epoll/kqueue/select, which park ops on a | |||
| 29 | descriptor_state) or completion-based (io_uring, which submits SQEs): | |||
| 30 | the file descriptor, the cached local endpoint, the impl lifecycle | |||
| 31 | bases (enable_shared_from_this + the service's intrusive tracking node), | |||
| 32 | and the synchronous accessors (native_handle / options / bind). | |||
| 33 | ||||
| 34 | reactor_basic_socket derives from this and adds the readiness machinery | |||
| 35 | (descriptor_state, register_op, the cancel/close that deregister from | |||
| 36 | the reactor). io_uring's socket impls derive from it and add their op | |||
| 37 | slots + SQE submission. This is the socket-layer analogue of io_uring | |||
| 38 | deriving from reactor_scheduler: io_uring sockets share the reactor's | |||
| 39 | readiness-agnostic socket surface, while the on-EAGAIN action (park vs | |||
| 40 | submit-SQE) and the op model stay backend-specific. | |||
| 41 | ||||
| 42 | @tparam Derived The concrete socket type (CRTP, for shared_from_this | |||
| 43 | and the intrusive node). | |||
| 44 | @tparam ImplBase The public vtable base (tcp_socket::implementation, | |||
| 45 | udp_socket::implementation, ...). | |||
| 46 | @tparam Endpoint The endpoint type (endpoint or local_endpoint). | |||
| 47 | */ | |||
| 48 | ||||
| 49 | namespace boost::corosio::detail { | |||
| 50 | ||||
| 51 | template<class Derived, class ImplBase, class Endpoint = endpoint> | |||
| 52 | class native_socket_base | |||
| 53 | : public ImplBase | |||
| 54 | , public std::enable_shared_from_this<Derived> | |||
| 55 | { | |||
| 56 | protected: | |||
| 57 | // CRTP base: not publicly constructible. The check's preferred fix | |||
| 58 | // (private ctor + `friend Derived`) is infeasible here — the reactor | |||
| 59 | // sockets reach this base through intermediate templates | |||
| 60 | // (reactor_stream_socket -> reactor_basic_socket) that are not `Derived`, | |||
| 61 | // so a private ctor would stop those intermediates from constructing it. | |||
| 62 | // Protected is the correct access; suppress the private-only suggestion. | |||
| 63 | 41200x | native_socket_base() = default; // NOLINT(bugprone-crtp-constructor-accessibility) | ||
| 64 | ||||
| 65 | 20600x | int fd_ = -1; | ||
| 66 | // mutable so a derived const local_endpoint() override can lazily fill | |||
| 67 | // it via getsockname() on first read (io_uring's lazy_pending state). | |||
| 68 | mutable Endpoint local_endpoint_; | |||
| 69 | ||||
| 70 | public: | |||
| 71 | 20600x | ~native_socket_base() override = default; | ||
| 72 | ||||
| 73 | /// Return the underlying file descriptor. | |||
| 74 | 65331x | native_handle_type native_handle() const noexcept override | ||
| 75 | { | |||
| 76 | 65331x | return fd_; | ||
| 77 | } | |||
| 78 | ||||
| 79 | /// Return the cached local endpoint. | |||
| 80 | 120x | Endpoint local_endpoint() const noexcept override | ||
| 81 | { | |||
| 82 | 120x | return local_endpoint_; | ||
| 83 | } | |||
| 84 | ||||
| 85 | /// Return true if the socket has an open file descriptor. | |||
| 86 | bool is_open() const noexcept | |||
| 87 | { | |||
| 88 | return fd_ >= 0; | |||
| 89 | } | |||
| 90 | ||||
| 91 | /// Set a socket option. | |||
| 92 | 100x | std::error_code set_option( | ||
| 93 | int level, int optname, void const* data, std::size_t size) | |||
| 94 | noexcept override | |||
| 95 | { | |||
| 96 |
10/32✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 40 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 32 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 10 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 10 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 40 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 8 times.
✓ Branch 23 taken 32 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 10 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 10 times.
|
100x | if (::setsockopt( | |
| 97 | 100x | fd_, level, optname, data, static_cast<socklen_t>(size)) != 0) | ||
| 98 |
2/16✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 8 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
|
16x | return make_err(errno); | |
| 99 | 84x | return {}; | ||
| 100 | 100x | } | ||
| 101 | ||||
| 102 | /// Get a socket option. | |||
| 103 | 132x | std::error_code get_option( | ||
| 104 | int level, int optname, void* data, std::size_t* size) | |||
| 105 | const noexcept override | |||
| 106 | { | |||
| 107 | 132x | socklen_t len = static_cast<socklen_t>(*size); | ||
| 108 |
10/32✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
✓ Branch 4 taken 64 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 64 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 2 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 22 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 22 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 2 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 2 times.
|
132x | if (::getsockopt(fd_, level, optname, data, &len) != 0) | |
| 109 | ✗ | return make_err(errno); | ||
| 110 | 132x | *size = static_cast<std::size_t>(len); | ||
| 111 | 132x | return {}; | ||
| 112 | 132x | } | ||
| 113 | ||||
| 114 | /// Assign the file descriptor. | |||
| 115 | 6610x | void set_socket(int fd) noexcept | ||
| 116 | { | |||
| 117 | 6610x | fd_ = fd; | ||
| 118 | 6610x | } | ||
| 119 | ||||
| 120 | /// Cache the local endpoint. | |||
| 121 | void set_local_endpoint(Endpoint ep) noexcept | |||
| 122 | { | |||
| 123 | local_endpoint_ = ep; | |||
| 124 | } | |||
| 125 | ||||
| 126 | /** Bind the socket to a local endpoint. | |||
| 127 | ||||
| 128 | Calls ::bind() and caches the resulting local endpoint via | |||
| 129 | getsockname(). Readiness-agnostic; usable by any fd backend. | |||
| 130 | ||||
| 131 | @param ep The endpoint to bind to. | |||
| 132 | @return Error code on failure, empty on success. | |||
| 133 | */ | |||
| 134 | 170x | std::error_code do_bind(Endpoint const& ep) noexcept | ||
| 135 | { | |||
| 136 | 170x | sockaddr_storage storage{}; | ||
| 137 | 170x | socklen_t addrlen = to_sockaddr(ep, socket_family(fd_), storage); | ||
| 138 |
18/24✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 55 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 53 times.
✓ Branch 8 taken 23 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 time.
✓ Branch 11 taken 22 times.
✓ Branch 12 taken 7 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2 times.
✓ Branch 15 taken 5 times.
✓ Branch 16 taken 55 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 2 times.
✓ Branch 19 taken 53 times.
✓ Branch 20 taken 23 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 1 time.
✓ Branch 23 taken 22 times.
|
170x | if (::bind(fd_, reinterpret_cast<sockaddr*>(&storage), addrlen) != 0) | |
| 139 |
6/12✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 time.
✗ Branch 11 not taken.
|
10x | return make_err(errno); | |
| 140 | ||||
| 141 | 160x | sockaddr_storage local_storage{}; | ||
| 142 | 160x | socklen_t local_len = sizeof(local_storage); | ||
| 143 |
12/24✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 53 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 53 times.
✓ Branch 8 taken 22 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 22 times.
✓ Branch 12 taken 5 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 5 times.
✓ Branch 16 taken 53 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 53 times.
✓ Branch 20 taken 22 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 22 times.
|
160x | if (::getsockname( | |
| 144 | 160x | fd_, reinterpret_cast<sockaddr*>(&local_storage), &local_len) | ||
| 145 | 160x | == 0) | ||
| 146 | 160x | local_endpoint_ = | ||
| 147 | 160x | from_sockaddr_as(local_storage, local_len, Endpoint{}); | ||
| 148 | ||||
| 149 | 160x | return {}; | ||
| 150 | 170x | } | ||
| 151 | }; | |||
| 152 | ||||
| 153 | } // namespace boost::corosio::detail | |||
| 154 | ||||
| 155 | #endif // BOOST_COROSIO_NATIVE_DETAIL_NATIVE_SOCKET_BASE_HPP | |||
| 156 |