UdpSocket connect "255.255.255.255"

    let socket = UdpSocket::bind("0.0.0.0:0").expect("couldn't bind to address");
    socket.connect("255.255.255.255:0").expect("connect function failed");

I encountered a problem when trying to create a UDP broadcast tool under Ubuntu: "thread 'main' panicked at 'connect function failed: OS {Code: 13, kind: permissiondenied, message:" permission denied "}'"

But there is no problem with the same code under windows. I don't know if there is any difference between Ubuntu and windows

But this problem has tortured me for a day. I look forward to the help of the boss
I work as root

By default a UdpSocket is not allowed to send on broadcast to do so you have to set UdpSocket::set_broadcast(true).

I'm surprised Windows ignores it.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.