[erlang-questions] is inet:gethostbyname( IP ) correct?

info <>
Fri Oct 16 16:24:53 CEST 2009


My idea was to analyse the return parameters because gethostbyname doesn't return "timeout".
Who and where decides to transform an error code in timeout code ?
I hope to escalade the problem like this ...
John
On Thu, Oct 15, 2009 at 03:02:40PM +0200, info wrote:
> Dear Raimo,
> I can resume: I discovered that gethostbyname call inet_gethost.c 
> I don't understand inet_gethost.c :-(
> Where "goes" this problem for finding the information ?
> If we know where and what, we could perhaps find what is missing in my windows 2003 ...
> Hope to read you soon !
> John

Well, there is not much more to say. inet_gethost.c calls
struct hostent *gethostbyname(const char *name) in the 
winsock2 library:
  http://msdn.microsoft.com/en-us/library/ms738524(VS.85).aspx
It never returns.
It is deprecated but that does not mean broken.
I have a Windows 2003 server that it works on.
We have not found the reason it differs between
my server and your server.
And that is about it.


> 
> On Wed, Oct 14, 2009 at 03:34:12PM +0200, info wrote:
>  > For me this function always returns {error,timeout} and I didn't find the reason even with the help of Raimo Niskanen !
> 
> Sorry about that, but your problem became a just too spooky
> Windows 2003 problem and that is not really my turf, and
> you seemed to have a possible workaround through inet_res.
> But it has been on my todo list to have a second look
> at the whole conversation when I could find the time...
> 
>  > 
>  > 
>  > At the end of my last mail you have the references.
>  > Regards,
>  > 
>  > Roberto Aloi
>  > Erlang Training and Consulting Ltd.
>  > http://www.erlang-consulting.com
>  > http://aloiroberto.wordpress.com
>  > 
>  > Robert Raschke wrote:
>  >   > This is part of the IP address spec (not sure where to look to find it,
>  >   > though). I've seen addresses specified like this on and off in various
>  >   > locations on a wide variety of OSes, for example in a /etc/hosts file you
>  >   > can write:
>  >   >
>  >   > localhost  127.1
>  >   >
>  >   > Robby
>  >   >
>  >   > On Tue, Oct 13, 2009 at 8:06 PM, caio ariede    <   > wrote:
>  >   >
>  >   >   
>  >   >   > Interesting case.
>  >   >   >
>  >   >   > The result doesn't appear to be an issue, but a feature of the
>  >   >   > gethostbyname
>  >   >   > original implementation, in C code.
>  >   >   >
>  >   >   > You get the same result, testing with PHP:
>  >   >   >
>  >   >   > $ php -r 'var_dump(gethostbyname("12.27"));'
>  >   >   > string(9) "12.0.0.27"
>  >   >   >
>  >   >   > And other interesting results:
>  >   >   >
>  >   >   > $ php -r 'var_dump(gethostbyname("255.2.256"));'
>  >   >   > string(9) "255.2.1.0"
>  >   >   >
>  >   >   > But I can't see where it's really useful.
>  >   >   >
>  >   >   > Caio Ariede
>  >   >   > http://caioariede.com/
>  >   >   >
>  >   >   >
>  >   >   > On Tue, Oct 13, 2009 at 3:15 PM, Garry Hodgson    <
>  >   >   >     
>  >   >   >   > wrote:
>  >   >   >   >       
>  >   >   >   > recently, a bug in my code caused us to pass a string
>  >   >   >   > representing a floating point number to inet:gethostbyname().
>  >   >   >   > i would have expected it to return an error, but instead it
>  >   >   >   > returned an ip address, but one that made no sense to me:
>  >   >   >   >
>  >   >   >   > 1   > inet:gethostbyname( '12.27' ).
>  >   >   >   > {ok,{hostent,"12.27",[],inet,4,[{12,0,0,27}]}}
>  >   >   >   >
>  >   >   >   > so my question is, is this behavior correct, and if so, what
>  >   >   >   > exactly does it mean that a lookup of '12.27' maps to '12.0.0.27'?
>  >   >   >   >
>  >   >   >   > thanks
>  >   >   >   >
>  >   >   >   > --
>  >   >   >   > Garry Hodgson
>  >   >   >   > Lead Member of Technical Staff
>  >   >   >   > AT&T Chief Security Office (CSO)
>  >   >   >   >
>  >   >   >   > "This e-mail and any files transmitted with it are AT&T property, are
>  >   >   >   > confidential, and are intended solely for the use of the individual or
>  >   >   >   > entity to whom this e-mail is addressed. If you are not one of the named
>  >   >   >   > recipient(s) or otherwise have reason to believe that you have received
>  >   >   >   >       
>  >   >   > this
>  >   >   >     
>  >   >   >   > message in error, please notify the sender and delete this message
>  >   >   >   > immediately from your computer. Any other use, retention, dissemination,
>  >   >   >   > forwarding, printing, or copying of this e-mail is strictly prohibited."
>  >   >   >   >
>  >   >   >   > ________________________________________________________________
>  >   >   >   > erlang-questions mailing list. See http://www.erlang.org/faq.html
>  >   >   >   > erlang-questions (at) erlang.org
>  >   >   >   >
>  >   >   >   >
>  >   >   >   >       
>  >   >
>  >   >   
>  > 
>  > 
>  > ________________________________________________________________
>  > erlang-questions mailing list. See http://www.erlang.org/faq.html
>  > erlang-questions (at) erlang.org
> 
> -- 
> 
> / Raimo Niskanen, Erlang/OTP, Ericsson AB
> 
> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB


More information about the erlang-questions mailing list