Git Product home page Git Product logo

Comments (5)

piotrek-szczygiel avatar piotrek-szczygiel commented on May 18, 2024

I would like to send broadcast on all interfaces.
I've already tried using 255.255.255.255 IP but that doesn't seem to work.

from libcluon.

piotrek-szczygiel avatar piotrek-szczygiel commented on May 18, 2024

Also seems like even doing something like 192.168.188.255 doesn't work.
So is there no way of sending broadcasts?

from libcluon.

chrberger avatar chrberger commented on May 18, 2024

Hi, just for me to understand: do you want to send data via broadcast using UDPSender or do you want to receive data sent from somewhere via broadcast using UDPReceiver?

from libcluon.

piotrek-szczygiel avatar piotrek-szczygiel commented on May 18, 2024

I'd like to send broadcast on all connected interfaces. For example when I'm connected to WiFi and Ethernet, I'd like to send broadcast on both of these interfaces.

Creating broadcasting sockets on every interface looks something like this in boost::asio:

    std::vector<ba::ip::udp::socket> sockets {};

    // Open one socket for every network interface
    ba::io_service io_service;
    ba::ip::tcp::resolver resolver(io_service);
    ba::ip::tcp::resolver::query query(ba::ip::host_name(), "");
    auto it = resolver.resolve(query);
    while (it != ba::ip::tcp::resolver::iterator()) {
        auto addr = (it++)->endpoint().address();
        if (addr.is_v4()) {
            ba::ip::udp::socket socket { m_ctx };
            boost::system::error_code ec;
            socket.open(ba::ip::udp::v4(), ec);
            if (ec) {
                BOOST_LOG_TRIVIAL(error) << "Unable to create broadcast socket on "
                                         << addr.to_string() << ": " << ec.message();
            } else {
                socket.set_option(ba::ip::udp::socket::reuse_address(true));
                socket.set_option(ba::socket_base::broadcast(true));
                socket.bind(ba::ip::udp::endpoint(addr, 0));

                sockets.push_back(std::move(socket));
            }
        }
    }

Also it seems like at the moment there is actually no way to send broadcast at all even when knowing the exact network address. I've tried creating UDPSender with address 192.168.188.255 (my ip was 192.168.188.21 with mask 255.255.255.0), but wireshark didn't intercept anything. I was only able to see any udp traffic when i chose unicast address as an endpoint.

from libcluon.

chrberger avatar chrberger commented on May 18, 2024

Added as of https://github.com/chrberger/libcluon/releases/tag/v0.0.128

from libcluon.

Related Issues (17)

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.