Skip to content

udp multicast send can't use specified local ip address #65

Description

@kkzi

code from examples/udp_multicast/main.cpp
it can't bind local ip address

kissnet::udp_socket mcast_send_socket(kissnet::endpoint(global_mcast_addr, global_mcast_port));
while (global_thread_running) {
    //Send the payload
    auto[sent_bytes, status] = mcast_send_socket.send(send_this, sizeof(send_this));
    if (sent_bytes != sizeof(send_this) || status != kissnet::socket_status::valid) {
        std::cout << "kissnet multicast send failure" << std::endl;
        break;
    }
    std::cout << "Sent multicast packet." << std::endl;

    //Wait for 100 milliseconds
    std::this_thread::sleep_for(std::chrono::milliseconds(100));
}

maybe we could do this to support binding local ip address

kissnet::endpoint remote { global_mcast_addr, global_mcast_port };
kissnet::udp_socket mcast_send_socket(kissnet::endpoint { "192.168.1.110", 0 });
mcast_send_socket.bind();
while (1)
{
    //Send the payload
    auto [sent_bytes, status] = mcast_send_socket.send(frame, remote);
    std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions