Socket

 view release on metacpan or  search on metacpan

Socket.pm  view on Meta::CPAN

    elsif( $flag_numerichost ) {
        $node = Socket::inet_ntoa( $inetaddr );
    }
    else {
        $node = gethostbyaddr( $inetaddr, $family );
        if( !defined $node ) {
            return fake_makeerr( EAI_NONAME() ) if $flag_namereqd;
            $node = Socket::inet_ntoa( $inetaddr );
        }
        elsif( $flag_nofqdn ) {
            my ( $shortname ) = split m/\./, $node;
            my ( $fqdn ) = gethostbyname $shortname;
            $node = $shortname if defined $fqdn and $fqdn eq $node;
        }
    }

    my $service;
    if( $xflags & NIx_NOSERV ) {
        $service = undef;
    }
    elsif( $flag_numericserv ) {

t/getaddrinfo.t  view on Meta::CPAN

    skip "Resolver has an answer for $missinghost", 1 if gethostbyname( $missinghost );

    # Some OSes return $err == 0 but no results
    ( $err, @res ) = getaddrinfo( $missinghost, "ftp", { socktype => SOCK_STREAM } );
    ok( $err != 0 || ( $err == 0 && @res == 0 ),
        '$err != 0 or @res == 0 for host=TbK4jM2M0OS.lm57DWIyu4i/service=ftp/socktype=SOCK_STREAM' );
    if( @res ) {
        # Diagnostic that might help
        while( my $r = shift @res ) {
            diag( "family=$r->{family} socktype=$r->{socktype} protocol=$r->{protocol} addr=[" . length( $r->{addr} ) . " bytes]" );
            diag( "  addr=" . join( ", ", map { sprintf '0x%02x', ord $_ } split m//, $r->{addr} ) );
        }
    }
}

# Numeric addresses with AI_NUMERICHOST should pass (RT95758)
AI_NUMERICHOST: {
    # Here we need a port that is open to the world. Not all places have all
    # the ports. For example Solaris by default doesn't have http/80 in
    # /etc/services, and that would fail. Let's try a couple of commonly open
    # ports, and hope one of them will succeed. Conversely this means that



( run in 1.010 second using v1.01-cache-2.11-cpan-71847e10f99 )