Closed gegles closed 5 years ago
I can confirm this problem on OSX. The problem does not occur on Linux.
Looks like the io_context returns immediately without waiting for pending operations, so the multiplexer destructor complains about those.
Further investigation shows that the async_receive_from()
with message_peek
in multiplexer::do_start_receive()
triggers the callback immediately, rather than when an incoming datagram has arrived.
Ah ah, yes, that's it, I remember facing that very same issue in a little POC I did. Somehow macOS does not like it if you pass it an empty buffer for the peek. I had to create a one byte peek_
buffer just for that:
socket_.async_receive_from(net::buffer(peek_), remote_endpoint_, net::socket_base::message_peek, [this](lib::error_code ec, std::size_t) {
if (ec) {
std::cerr << "UDP Accept error: " << ec.message() << "\n";
return;
}
std::cout << "Accepted! local=" << socket_.local_endpoint() << " remote=" << remote_endpoint_ << "\n";
socket_.connect(remote_endpoint_);
std::make_shared<Session>(std::move(socket_))->Start();
DoAccept();
});
}
std::uint16_t port_;
udp::socket socket_;
udp::endpoint remote_endpoint_;
std::array<char, 1> peek_;
You may know of a better way to solve this..
Unless you can fix it fast, I'll try to submit a PR when I get to it. thanks!
Thanks, that works.
Committed in 24f3a908f1634f7924501d8846a5ee7568966d85
You da man! Thanks! it works.
Hello,
(Potentially an awesome library, thanks!). I was just trying to run the example and got the following error when running
async_echo_server
:I am running this on macOS (Catalina). Any clue, am I missing something?