6 require Config; import Config;
7 if ($Config{'extensions'} !~ /\bSocket\b/ &&
8 !(($^O eq 'VMS') && $Config{d_socket})) {
9 print "1..0 # Test uses Socket, Socket not built\n";
14 BEGIN { $| = 1; print "1..5\n"; }
16 END {print "not ok 1\n" unless $loaded;}
23 # test basic resolution of localhost <-> 127.0.0.1
26 my $h = gethost('localhost');
27 print +(defined $h ? '' : 'not ') . "ok 2\n";
28 my $i = gethostbyaddr(inet_aton("127.0.0.1"));
29 print +(!defined $i ? 'not ' : '') . "ok 3\n";
31 print "not " if inet_ntoa($h->addr) ne "127.0.0.1";
34 print "not " if inet_ntoa($i->addr) ne "127.0.0.1";
37 # need to skip the name comparisons on Win32 because windows will
38 # return the name of the machine instead of "localhost" when resolving
39 # 127.0.0.1 or even "localhost"
41 # VMS returns "LOCALHOST" under tcp/ip services V4.1 ECO 2, possibly others
42 # OS/390 returns localhost.YADDA.YADDA
44 if ($^O eq 'MSWin32') {
45 print "ok $_ # skipped on win32\n" for (6,7);
47 print "not " unless $h->name =~ /^localhost(?:\..+)?$/i;
48 print "ok 6 # ",$h->name,"\n";
50 print "not " unless $i->name =~ /^localhost(?:\..+)?$/i;
51 print "ok 7 # ",$i->name,"\n";