Commit | Line | Data |
fedf0971 |
1 | #!./perl -w |
2 | |
3 | BEGIN { |
4 | chdir 't' if -d 't'; |
5 | @INC = '../lib'; |
6 | } |
7 | |
8 | BEGIN { $| = 1; print "1..5\n"; } |
9 | |
10 | END {print "not ok 1\n" unless $loaded;} |
11 | |
12 | use Net::hostent; |
13 | |
14 | $loaded = 1; |
15 | print "ok 1\n"; |
16 | |
17 | # test basic resolution of localhost <-> 127.0.0.1 |
18 | use Socket; |
19 | |
20 | my $h = gethost('localhost'); |
21 | my $i = gethostbyaddr(inet_aton("127.0.0.1")); |
22 | |
23 | print "not " if inet_ntoa($h->addr) ne "127.0.0.1"; |
24 | print "ok 2\n"; |
25 | |
26 | print "not " if inet_ntoa($i->addr) ne "127.0.0.1"; |
27 | print "ok 3\n"; |
28 | |
29 | # need to skip the name comparisons on Win32 because windows will |
30 | # return the name of the machine instead of "localhost" when resolving |
31 | # 127.0.0.1 or even "localhost" |
32 | |
d26aeb84 |
33 | # VMS returns "LOCALHOST" under tcp/ip services V4.1 ECO 2, possibly others |
84bf2719 |
34 | # OS/390 returns localhost.YADDA.YADDA |
d26aeb84 |
35 | |
fedf0971 |
36 | if ($^O eq 'MSWin32') { |
37 | print "ok $_ # skipped on win32\n" for (4,5); |
38 | } else { |
84bf2719 |
39 | print "not " unless $h->name =~ /^localhost(?:\..+)?$/i; |
d26aeb84 |
40 | print "ok 4 # ",$h->name,"\n"; |
fedf0971 |
41 | |
84bf2719 |
42 | print "not " unless $i->name =~ /^localhost(?:\..+)?$/i; |
d26aeb84 |
43 | print "ok 5 # ",$i->name,"\n"; |
fedf0971 |
44 | } |