develooper Front page | perl.perl5.porters | Postings from January 2017

Re: [perl #88080] Listen to socket does not return when host isundefined or 0.0.0.0.

Thread Next
From:
Bo Johansson
Date:
January 1, 2017 10:35
Subject:
Re: [perl #88080] Listen to socket does not return when host isundefined or 0.0.0.0.
Message ID:
bec4b21e-61a4-77dc-4bdc-0056d121e8d4@lsn.se
Hej!

I have run:

    use strict;
    use warnings;

    use HTTP::Server::Simple;

    my $server = HTTP::Server::Simple->new();
    $server->host( undef );
    #$server->host( '0.0.0.0' );
    $server->run();

Using "$server->host( undef );" or "$server->host( '0.0.0.0' );" works 
with HTTP::Server::Simple version 0.51!

Best regards
Bo Johansson

Den 2016-12-31 kl. 16:14, skrev James E Keenan via RT:
> On Fri, 08 Apr 2011 08:47:19 GMT, boilund wrote:
>> This is a bug report for perl from bo.johansson@lsn.se,
>> generated with the help of perlbug 1.39 running under perl 5.12.2.
>>
>>
>> -----------------------------------------------------------------
>> [Please describe your issue here]
>>
>> The perl function listen does not return when host is undefined or
>> 0.0.0.0.
>> Sometimes it also gets Windows 7 in unstable state and normal shut
>> down is impossible.
>>
>> Example: 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: $!";
>> }
>>
>> If $self->host is undefined or '0.0.0.0' the call to listen does not
>> return.
>>    Sometimes it gets Windows 7 in unstable state and
>>
> Can the problem with Perl function 'listen' (assuming there *is* a problem) be demonstrated apart from this use in HTTP::Server::Simple?
>
> The code provided is not sufficient to reproduce the problem (at least by a person not already familiar with that module).
>
> Thank you very much.
>


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About