Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I have problem with the tests in HTTP-Server-Simple-0.44.
I am using:
- Strawberry-perl-5.12.2.0
- Perl 5, version 12, subversion 2 (v5.12.2) built for MSWin32-x86-multi-thread
- Windows 7 Home Premium with Service Pack 1
This is setup_listener from HTTP-Server-Simple-0.44/lib/HTTP/Server/Simple.pm
sub setup_listener { my $self = shift; my $tcp = getprotobyname('tcp'); socket( HTTPDaemon, PF_INET, SOCK_STREAM, $tcp ) or croak "socket: + $!"; setsockopt( HTTPDaemon, SOL_SOCKET, SO_REUSEADDR, pack( "l", 1 ) ) or warn "setsockopt: $!"; bind( HTTPDaemon, sockaddr_in( $self->port(), ( $self->host ? inet_aton( $self->host ) : INADDR_ANY ) ) ) or croak "bind to @{[$self->host||'*']}:@{[$self->port]}: $!"; listen( HTTPDaemon, SOMAXCONN ) or croak "listen: $!"; }
When running some of tests, $self->host is undefined and the call to listen does not return (and sometimes get Windows 7 in blocked state). ($self->host with the value '0.0.0.0' used by Plack does also not work.)
Adding this before bind is a workaround
$self->host('localhost') if ! defined $self->host; $self->host('localhost') if $self->host eq '0.0.0.0';
Is this a bug in Windows or what is a proper solution?
Back to
Seekers of Perl Wisdom