let addr = "239.255.255.250:1982";
let socket = UdpSocket::bind(addr).unwrap();
let message = "some message".as_bytes();
socket.send_to(message, addr).unwrap();
This code gives the following error for the last line:
Error { repr: Os { code: 49, message: "Can\'t assign requested address" } }
Why would that be the case?
EDIT: I tried the following as suggested:
let addr = "239.255.255.250:1982";
let socket = UdpSocket::bind("127.0.0.1:34254").unwrap();
let message = "some message".as_bytes();
socket.send_to(message, addr).unwrap();
But that didn't change anything, unfortunately.
The address you used to bind your UdpSocket
to is a multicast address.
The argument to UdpSocket::bind
should be the local address you send from.
The docs use 127.0.0.1:34254
. If it is not currently being used, this should work for you. Additionally you can give it an array of potential adresses to use.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With