[erlang-bugs] : inet_res:getbyname

Raimo Niskanen raimo+erlang-bugs@REDACTED
Fri Sep 7 10:13:47 CEST 2007


The general call is inet:gethostbyname/2. See erl -man inet.
There are lots of useful functions there.

inet:gethostbyname/2 will in its turn call inet_res:getbyname/2
if 'dns' is in the list returned from inet_db:res_option(lookup).
See http://www.erlang.org/doc/apps/erts/part_frame.html:
"7 Inet configuration", option 'lookup'.

But the default configuration is to have only 'native' in
the lookup option list, which will make inet:gethostbyname
call inet_gethost_native:gethostbyname, that itself uses
a pool of external port programs that call the C resolver
library functions.

How did you stumble on the inet_res module? It is not documented.



On Thu, Sep 06, 2007 at 09:08:43AM -0500, Matthew O'Gorman wrote:
> oh im sorry i didn't see that it was deprecated.  What is the
> replacement for what I am trying to do, or is there no replacement you
> just don't intend to support it anymore?
> 
> Matt
> 
> On 9/6/07, Raimo Niskanen <raimo+erlang-bugs@REDACTED> wrote:
> > Well, since this resolver is kind of deprecated; not really - we have
> > paying customers using it, but almost deprecated. The native resolver
> > is the one we want everyone to use since it calls the OS resolver
> > and therefore should be perfectly bug compatible.
> >
> > Anyway, we have no strong reasons to put a lot of work into
> > inet_res. But if it behaves strangely and we can fix it
> > easily we will do it.
> >
> > I took a quick look into ets:tab2list(inet_db) for both
> > -sname and -name and it seems res_domain, res_ns and
> > res_search does not get initialized if started with
> > -sname. It seems my host resolver configuration file is
> > not read (/etc/resolv.conf). This rings a bell about
> > cleanups we did about which host configuration files
> > are read at startup (/etc{resolv.conf,nsswitch.conf,
> > hosts,host.conf,irs.conf,...}. It was a mess and very bug prone.
> > The idea is that the native resolver does it right
> > so we shall use it.
> >
> > I have to talk to some people...
> >
> > Anyway, this means there are workarounds, at least using
> > the infamous inetrc file, to set an inet_res configuration of your own.
> >
> >
> >
> > On Wed, Sep 05, 2007 at 07:01:57PM -0500, Matthew O'Gorman wrote:
> > > inet_res:getbyname fails unless started with -name
> > >
> > >  erl
> > >
> > > Erlang (BEAM) emulator version 5.5.5 [source] [64-bit]
> > > [async-threads:0] [hipe] [kernel-poll:false]
> > >
> > >
> > >
> > > Eshell V5.5.5  (abort with ^G)
> > >
> > > 1> inet_res:getbyname("_xmpp-server._tcp.digium.com",srv).
> > >
> > > {error,timeout}
> > >
> > > 2>
> > >
> > >
> > >
> > >  erl -sname matt
> > >
> > > Erlang (BEAM) emulator version 5.5.5 [source] [64-bit]
> > > [async-threads:0] [hipe] [kernel-poll:false]
> > >
> > >
> > >
> > > Eshell V5.5.5  (abort with ^G)
> > >
> > > (matt@REDACTED)1> inet_res:getbyname("_xmpp-server._tcp.digium.com",srv).
> > >
> > > {error,timeout}
> > >
> > > (matt@REDACTED)2>
> > >
> > >
> > >
> > > erl -name matt
> > >
> > > Erlang (BEAM) emulator version 5.5.5 [source] [64-bit]
> > > [async-threads:0] [hipe] [kernel-poll:false]
> > >
> > >
> > >
> > > Eshell V5.5.5  (abort with ^G)
> > >
> > > (matt@REDACTED)1>
> > > inet_res:getbyname("_xmpp-server._tcp.digium.com",srv).
> > >
> > > {ok,{hostent,"_xmpp-server._tcp.digium.com",
> > >
> > >              [],
> > >
> > >              srv,
> > >
> > >              1,
> > >
> > >              [{5,0,5269,"jabber.digium.com"}]}}
> > >
> > > (matt@REDACTED)2>
> > >
> > >
> > >
> > >
> > > This seems to have existed since r10b i was wondering if there are any
> > > intentions on ever fixing it?
> > >
> > > Mog
> > > _______________________________________________
> > > erlang-bugs mailing list
> > > erlang-bugs@REDACTED
> > > http://www.erlang.org/mailman/listinfo/erlang-bugs
> >
> > --
> >
> > / Raimo Niskanen, Erlang/OTP, Ericsson AB
> >
> _______________________________________________
> erlang-bugs mailing list
> erlang-bugs@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-bugs

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



More information about the erlang-bugs mailing list