in reply to Re^3: gethostbyname returns reverse order of ipaddress expected
in thread gethostbyname returns reverse order of ipaddress expected

As I described in the 2 outputs, the C# one returns addresses in the correct order (increasing interface metric) while the perl one returns it in the reverse order (decreasing metric). It has nothing to do with the byte order of the individual ip address.
  • Comment on Re^4: gethostbyname returns reverse order of ipaddress expected

Replies are listed 'Best First'.
Re^5: gethostbyname returns reverse order of ipaddress expected
by Anonymous Monk on Jun 26, 2013 at 02:15 UTC

    all perl does is call the system gethostbyname and returns the results, it doesn't reorder them; if the results don't match whatever C# does, if it doesn't match your expectations, doesn't mean the results are wrong

      You are right. .NET gethostbyname actually calls getaddrinfo in some cases. getaddrinfo returns the addresses in "correct" order which gethostbyname does not on Windows. Hence the discrepancy. tried a native app which calls both and confirmed the difference. Thanks everyone.