MOON
Server: Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4
System: Linux vps.panamaemb.org.sg 3.10.0-1160.80.1.vz7.191.4 #1 SMP Thu Dec 15 20:31:06 MSK 2022 x86_64
User: panama (500)
PHP: 5.2.17
Disabled: NONE
Upload Files
File: //proc/2/cwd/installd/perl588installer/libwww-perl-5.823/talk-to-ourself
#!perl -w

# This program check if we are able to talk to ourself.  Misconfigured
# systems that can't talk to their own 'hostname' was the most commonly
# reported libwww-failure.

use strict;
require IO::Socket;

if (@ARGV >= 2 && $ARGV[0] eq "--port") {
    my $port = $ARGV[1];
    require Sys::Hostname;
    my $host = Sys::Hostname::hostname();
    if (my $socket = IO::Socket::INET->new(PeerAddr => "$host:$port", Timeout => 5)) {
	require IO::Select;
	if (IO::Select->new($socket)->can_read(1)) {
	    my($n, $buf);
	    if ($n = sysread($socket, $buf, 512)) {
		exit if $buf eq "Hi there!\n";
		die "Seems to be talking to the wrong server at $host:$port, got \"$buf\"\n";
	    }
	    elsif (defined $n) {
		die "Immediate EOF from server at $host:$port\n";
	    }
	    else {
		die "Can't read from server at $host:$port: $!";
	    }
	}
	die "No response from server at $host:$port\n";
    }
    die "Can't connect: $@\n";
}

# server code
my $socket = IO::Socket::INET->new(Listen => 1, Timeout => 5);
my $port = $socket->sockport;
open(CLIENT, qq("$^X" "$0" --port $port |)) || die "Can't run $^X $0: $!\n";

if (my $client = $socket->accept) {
    print $client "Hi there!\n";
    close($client) || die "Can't close socket: $!";
}
else {
    warn "Test server timeout\n";
}

exit if close(CLIENT);
die "Can't wait for client: $!" if $!;
die "The can-we-talk-to-ourself test failed.\n";