in reply to Re: gethostbyname returns reverse order of ipaddress expected
in thread gethostbyname returns reverse order of ipaddress expected
Outputs via C# and perl
>listaddrcsharp.exe 10.123.67.139 192.168.0.1
>perl d:\temp\in.pl 192.168.0.1 10.123.67.139
Perl codeC# Codeuse Socket; use IO::Socket; my $machineName = lc($ENV{COMPUTERNAME}); my ($name, $aliases, $addrtype, $length, @addrs) = gethostbyname($mach +ineName); foreach(@addrs) { ($a,$b,$c,$d)=unpack ('C4', $_); print "$a.$b.$c.$d\n"; }
public static void Main(string[] args) { IPAddress[] ips; ips = Dns.GetHostAddresses(Environment.MachineName); foreach (IPAddress ip in ips) { if (ip.AddressFamily == AddressFamily.InterNetwork) Console.WriteLine(" {0}", ip); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: gethostbyname returns reverse order of ipaddress expected
by Anonymous Monk on Jun 18, 2013 at 04:13 UTC | |
by Anonymous Monk on Jun 25, 2013 at 22:20 UTC | |
by Anonymous Monk on Jun 26, 2013 at 02:15 UTC | |
by anubhavd (Initiate) on Jun 26, 2013 at 19:11 UTC |