Coder Social home page Coder Social logo

Comments (5)

breese avatar breese commented on July 25, 2024

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.

from trial.datagram.

breese avatar breese commented on July 25, 2024

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.

from trial.datagram.

gegles avatar gegles commented on July 25, 2024

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!

from trial.datagram.

breese avatar breese commented on July 25, 2024

Thanks, that works.

Committed in 24f3a90

from trial.datagram.

gegles avatar gegles commented on July 25, 2024

You da man! Thanks! it works.

from trial.datagram.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.