Subject: | mcast_send() not working with Perl 5.28 |
Hello,
mcast_send() returns "Invalid argument" with Perl 5.28.
This code:
my $s = IO::Socket::Multicast->new(LocalPort=>1100);
$s->mcast_send('hello world!','225.0.0.1:1200') or die "$!";
results in:
Invalid argument at ./test.pl line 6.
To fix this, I used the int() function for the port number in mcast_dest(), see attached patch.
All the best,
Andreas Ebertus
Subject: | sockaddr_in_perl-5.28.patch |
--- a/lib/IO/Socket/Multicast.pm 2019-09-27 22:24:18.358025842 +0200
+++ b/lib/IO/Socket/Multicast.pm 2019-09-27 22:24:28.548756284 +0200
@@ -99,7 +99,7 @@
my $sock = shift;
my $prev = ${*$sock}{'io_socket_mcast_dest'};
if (my $dest = shift) {
- $dest = sockaddr_in($2,inet_aton($1)) if $dest =~ /^($IP):(\d+)$/;
+ $dest = sockaddr_in(int($2),inet_aton($1)) if $dest =~ /^($IP):(\d+)$/;
croak "invalid destination address" unless length($dest) == 16;
${*$sock}{'io_socket_mcast_dest'} = $dest;
}