No loud objections from the public gallery, so I've uploaded it, with
some behavioural changes and documentation:

  http://search.cpan.org/perldoc?Socket::GetAddrInfo

One thing I found while testing it, was that various platforms differ a
lot in their own behaviour of getaddrinfo(). The emulated version in the
perl module emulates GNU's libc as best as I can. I compared it against
Solaris 10 and with the help of some people on #perl/Freenode,
comparisons were also made with some BSDs.

What I found was differences in how getaddrinfo( "localhost", "" ) or
similar requests that lack a service name all behave.

 * GNU libc on Linux will return three possible answers:

      AF_INET / SOCK_STREAM / IPPROTO_TCP
      AF_INET / SOCK_DGRAM  / IPPROTO_UDP
      AF_INET / SOCK_RAW    / 0

 * Solaris will only return one answer:

      AF_INET / 0           / 0

   I also found that Solaris will never fill in the protocol number even
   for specifically-named service entries; it always leaves 0.

 * BSD will return two answers:

      AF_INET / SOCK_DGRAM  / IPPROTO_UDP
      AF_INET / SOCK_STREAM / IPPROTO_TCP

These differences meant I couldn't employ a testing strategy of simply
comparing the emulated function with the platform's real one.

I don't think any of these approaches is more "correct" than any other;
at least, nothing I can find in documentation suggests any are wrong.

I'd be interested to hear any other reports from other operating systems;
the helper script t/10compare-getaddrinfo.pm will generate some useful
output to compare the real and emulated versions.

-- 
Paul "LeoNerd" Evans

[EMAIL PROTECTED]
ICQ# 4135350       |  Registered Linux# 179460
http://www.leonerd.org.uk/

Attachment: signature.asc
Description: PGP signature

Reply via email to