Why doesn't the Rust UDP listener programme work?
I'm playing with some UDP socket code and also learning Rust.
In this toy exmaple the listener programme should block waiting to receive a packet and when it does, print the result and exit.
The Ruby code works as I expect but the Rust version of the listener blocks forever apparently not receiving anything.
I've attempted to make these code samples as concise as possible.
Help appreciated!
It turns out that this is an IPv4 vs IPv6 issue. Rust creates an AF_INET6 socket even with
localhost:2222
as the bind address.Setting the bind address like so makes it work: