Skip to content

Add UDP multicast support #78

@adityarao2005

Description

@adityarao2005

This issue adds UDP multicast support in the form of a multicast socket. Multicast sockets can "join" groups and you can send a message to those "groups" and receive messages from those groups (or other people).

I'm thinking of something like this:

multicast_group group = multicast_group::resolve(ipv4::addr("././././"))

multicast_socket sock;

sock.bind({ "0.0.0.0", "0" })
await sock.join(group, {})

while (true) {
     std::array<char, 4096> bytes;
     connection_info info;

    auto size = co_await sock.recvfrom(bytes, info);

    std::cout << "IP addr of sender: " << info.addr << ", port of sender: " << info.port << std::endl;
    std::cout << "Bytes sent: " << size << std::endl;
    
    co_await sock.sendto("Hello World", group);

    // some condition to close
    if (condition_to_close()) {
           break;
    }
}

co_await sock.close()

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions