• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jbaldwin / libcoro / 18380866254

09 Oct 2025 03:36PM UTC coverage: 88.746%. First build
18380866254

Pull #400

github

web-flow
Merge 74fd4d1f9 into 749e5b474
Pull Request #400: Executor types remove circular refs

48 of 56 new or added lines in 15 files covered. (85.71%)

1656 of 1866 relevant lines covered (88.75%)

5388609.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

58.06
/src/net/tcp/server.cpp
1
#include "coro/net/tcp/server.hpp"
2

3
#include "coro/io_scheduler.hpp"
4

5
namespace coro::net::tcp
6
{
7
server::server(std::unique_ptr<coro::io_scheduler>& scheduler, options opts)
14✔
8
    : m_io_scheduler(scheduler.get()),
14✔
9
      m_options(std::move(opts)),
13✔
10
      m_accept_socket(
13✔
11
          net::make_accept_socket(
12
              net::socket::options{net::domain_t::ipv4, net::socket::type_t::tcp, net::socket::blocking_t::no},
×
13
              m_options.address,
13✔
14
              m_options.port,
13✔
15
              m_options.backlog))
16
{
17
    if (m_io_scheduler == nullptr)
14✔
18
    {
19
        throw std::runtime_error{"tcp::server cannot have a nullptr io_scheduler"};
×
20
    }
21
}
14✔
22

23
server::server(server&& other)
×
NEW
24
    : m_io_scheduler(std::exchange(other.m_io_scheduler, nullptr)),
×
25
      m_options(std::move(other.m_options)),
×
26
      m_accept_socket(std::move(other.m_accept_socket))
×
27
{
28
}
×
29

30
auto server::operator=(server&& other) -> server&
×
31
{
32
    if (std::addressof(other) != this)
×
33
    {
NEW
34
        m_io_scheduler  = std::exchange(other.m_io_scheduler, nullptr);
×
35
        m_options       = std::move(other.m_options);
×
36
        m_accept_socket = std::move(other.m_accept_socket);
×
37
    }
38
    return *this;
×
39
}
40

41
auto server::accept() -> coro::net::tcp::client
203✔
42
{
43
    sockaddr_in         client{};
203✔
44
    constexpr const int len = sizeof(struct sockaddr_in);
203✔
45
    net::socket         s{::accept(
46
        m_accept_socket.native_handle(),
47
        reinterpret_cast<struct sockaddr*>(&client),
48
        const_cast<socklen_t*>(reinterpret_cast<const socklen_t*>(&len)))};
203✔
49

50
    std::span<const uint8_t> ip_addr_view{
51
        reinterpret_cast<uint8_t*>(&client.sin_addr.s_addr),
52
        sizeof(client.sin_addr.s_addr),
53
    };
203✔
54

55
    return tcp::client{
56
        m_io_scheduler,
57
        std::move(s),
203✔
58
        client::options{
59
            .address = net::ip_address{ip_addr_view, static_cast<net::domain_t>(client.sin_family)},
203✔
60
            .port    = ntohs(client.sin_port),
203✔
61
        }};
406✔
62
};
203✔
63

64
} // namespace coro::net::tcp
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc