Unix Programming - gethostbyname works with AF_INET6?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > January 2008 > gethostbyname works with AF_INET6?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author gethostbyname works with AF_INET6?
Jingjing

2008-01-03, 7:23 pm

I have searched and found thousands of questions regarding
gethostbyname, but I didn't find what I need.

I'm reading UNPv1. On page 307, it's written gethostbyname() only
returns IPv4 addresses (and the POSIX specs confirmed this claim). In
the answer to exercise 11.5 (page 932), I saw the following test
statements:

if (hp->h_addrtype == AF_INET) {
...
} else if (hp->h_addrtype == AF_INET6) {
...
} else
...

h_addrtype is used to determine the type of address, as they said.
This clearly conflicts what's claimed before. Any ideas?
Rick Jones

2008-01-03, 7:23 pm

Unless you know beyond a shadow of a doubt that the platform(s) on
which you will be deploying your code have no getaddrinfo() support
and you are unable to provide your own version (there are some out
there) as a replacement on those systems, you should be using
getaddrinfo() (and getnodeinfo()) instead of gethostbyname() (and
gethostbyaddr()).

The getaddrinfo by definition will support AF_INET6.

rick jones
--
oxymoron n, commuter in a gas-guzzling luxury SUV with an American flag
these opinions are mine, all mine; HP might not want them anyway...
feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH...
Rainer Weikusat

2008-01-03, 7:23 pm

Rick Jones <rick.jones2@hp.com> writes:
> Unless you know beyond a shadow of a doubt that the platform(s) on
> which you will be deploying your code have no getaddrinfo() support
> and you are unable to provide your own version (there are some out
> there) as a replacement on those systems, you should be using
> getaddrinfo() (and getnodeinfo()) instead of gethostbyname() (and
> gethostbyaddr()).


Unless you can take advantage of something getmoderinzedwhatever
provides, the additional effort isn't worth it.
dj3vande@csclub.uwaterloo.ca.invalid

2008-01-03, 7:23 pm

In article <877iiqlgk0.fsf@fever.mssgmbh.com>,
Rainer Weikusat <rweikusat@mssgmbh.com> wrote:
>Rick Jones <rick.jones2@hp.com> writes:
>
>Unless you can take advantage of something getmoderinzedwhatever
>provides, the additional effort isn't worth it.


I find that, at least in this case, the additional effort is negative.


dave
(if it ALWAYS worked that way, the world would be a much better place)

Jingjing

2008-01-03, 7:23 pm

On Jan 3, 5:23=A0pm, dj3va...@csclub.uwaterloo.ca.invalid wrote:
> In article <877iiqlgk0....@fever.mssgmbh.com>,
> Rainer Weikusat =A0<rweiku...@mssgmbh.com> wrote:
>
>
>
> I find that, at least in this case, the additional effort is negative.
>
> dave
> (if it ALWAYS worked that way, the world would be a much better place)


I do know getaddrinfo() and getnameinfo() should be used whenever
possible
since they are protocol-independent and gethostbyname() will probably
be
removed in the future POSIX specs. However, here I'm talking about an
exercise in UNPv1. I'm curious why the solution conflicts what's
claimed
in the text?

Thanks for the discussion anyway.

Jingjing
Rick Jones

2008-01-03, 7:23 pm

Rainer Weikusat <rweikusat@mssgmbh.com> wrote:
> Unless you can take advantage of something getmoderinzedwhatever
> provides, the additional effort isn't worth it.


My experience with netperf was it actually made the code simpler. YMMV.

rick jones
--
The glass is neither half-empty nor half-full. The glass has a leak.
The real question is "Can it be patched?"
these opinions are mine, all mine; HP might not want them anyway...
feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH...
Rick Jones

2008-01-03, 7:23 pm

Jingjing <duanjingjing@gmail.com> wrote:
> I do know getaddrinfo() and getnameinfo() should be used whenever
> possible since they are protocol-independent and gethostbyname()
> will probably be removed in the future POSIX specs. However, here
> I'm talking about an exercise in UNPv1. I'm curious why the solution
> conflicts what's claimed in the text?


I'm not sure I'd read too much into that being present in the code.
It could just be a cut-and-paste thing. There were gethostbyname()
variants which did support IPv6, perhaps the code dated from that era
and didn't get cleaned-up by the time of publication and was missed by
the reviewers

rick jones
--
No need to believe in either side, or any side. There is no cause.
There's only yourself. The belief is in your own precision. - Jobert
these opinions are mine, all mine; HP might not want them anyway...
feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH...
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com