Hello Perl6 users, I've recently been made aware of a hole in our UDP support: you can't get the source address and port of datagrams you receive, which is an integral part of the UDP experience.
I've sketched out a piece of code to implement passing address and port from moarvm to rakudo, but I'm not happy with the API yet. Here's a taste: my $do-encoding = True; react { my $socket = IO::Socket::Async.bind-udp('localhost', 3333); if $do-encoding { # set an encoding to get the data as a string whenever $socket.Supply(:datagrams, :enc<utf8>).head(100) { say "we got the text $_.data.perl() from $_.hostname():$_.port()"; } } else { # or get the datagrams with Blobs containing the data whenever $socket.Supply(:datagrams).head(100) { say "the bytes in the message were $_.data.perl(), it came from $_.hostname():$_.port()."; } } } The objects you get from the supply in this case are of type IO::Socket::Async::Datagram In particular I'd like a better name for the named argument that turns "datagram mode" on; maybe just change it from :datagrams to :datagram. And perhaps the Datagram class wants to live under another namespace. We don't support synchronous UDP sockets, though, so maybe IO::Socket::Async is the right namespace after all. If you want to play with the udp support, there's a moarvm branch and a rakudo branch both named "udp_receive_hostname_port". You can also comment on the proposal on github and follow additional commits made in the mean time: https://github.com/rakudo/rakudo/pull/1473 Thank you for your time. - Timo