Subject: | Fails to listen() without bind() on windows |
This test script fails on windows with message "Invalid argument at t.pl line 5."
use strict;
use lib 'IO-Socket-IP-0.35/lib';
use IO::Socket::IP;
my $srv = IO::Socket::IP->new(Listen => 1)
or die $@;
warn "server started at [", $srv->sockhost, "]:", $srv->sockport;
__END__
Tested on windows XP and windows 7
This is because IO::Socket::IP will not call bind() before listen() when nor LocalAddr nor LocalPort specified. After this patch we'll get appropriate address to bind to using getaddrinfo('', 0, $hints)
Subject: | need-to-bind-on-win32.patch |
--- lib/IO/Socket/IP.pm.orig 2015-01-08 13:36:32.107708416 +0600
+++ lib/IO/Socket/IP.pm 2015-01-08 13:34:10.351015399 +0600
@@ -441,10 +441,14 @@
ref $info eq "ARRAY" or croak "Expected 'LocalAddrInfo' to be an ARRAY ref";
@localinfos = @$info;
}
- elsif( defined $arg->{LocalHost} or defined $arg->{LocalService} ) {
+ elsif( defined $arg->{LocalHost} or defined $arg->{LocalService} or ($^O eq 'MSWin32' && $arg->{Listen}) ) {
# Either may be undef
my $host = $arg->{LocalHost};
my $service = $arg->{LocalService};
+
+ unless ( defined $host or defined $service ) {
+ $service = 0;
+ }
local $1; # Placate a taint-related bug; [perl #67962]
defined $service and $service =~ s/\((\d+)\)$// and