gethostbyname works with AF_INET6?
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > gethostbyname works with AF_INET6?




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    gethostbyname works with AF_INET6?  
Jingjing


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-04-08 12:23 AM

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?





[ Post a follow-up to this message ]



    Re: gethostbyname works with AF_INET6?  
Rick Jones


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-04-08 12:23 AM

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...





[ Post a follow-up to this message ]



    Re: gethostbyname works with AF_INET6?  
Rainer Weikusat


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-04-08 12:23 AM

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.





[ Post a follow-up to this message ]



    Re: gethostbyname works with AF_INET6?  
dj3vande@csclub.uwaterloo.ca.invalid


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-04-08 12:23 AM

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)






[ Post a follow-up to this message ]



    Re: gethostbyname works with AF_INET6?  
Jingjing


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-04-08 12:23 AM

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





[ Post a follow-up to this message ]



    Re: gethostbyname works with AF_INET6?  
Rick Jones


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-04-08 12:23 AM

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...





[ Post a follow-up to this message ]



    Re: gethostbyname works with AF_INET6?  
Rick Jones


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-04-08 12:23 AM

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...





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 06:43 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register