[erlang-questions] inet_res:getbyname/2 and udp:connect/3

Raimo Niskanen raimo+erlang-questions@REDACTED
Wed Jun 16 15:55:35 CEST 2010


On Wed, Jun 16, 2010 at 04:47:48PM +0400, Dmitry Belyaev wrote:
> Try to add one working nameserver after 127.0.0.1 like this (like for my 
> router):
> 
> inet_res:resolve("www.rogvall.se", in, a, [{nameservers,[{{127,0,0,1},53}, 
> {{192,168,0,1},53}]},verbose], 5000).
> 
> Even if second server is working, the result will be the same.

That bug is on my todo list...

> 
> Dmitry Belyaev
> 
> 
> On 06/16/2010 04:35 PM, Tony Rogvall wrote:
> >
> >On 16 jun 2010, at 08.07, Per Hedeland wrote:
> >
> >   
> >>     
> >>>Try an other interface where there is a host ...
> >>>       
> >>Haven't done that, maybe I will (right now I happen to be on a network
> >>where other hosts don't have the courtesy to send ICMP unreachables:-).
> >>I noticed something else interesting though - in passive mode:
> >>
> >>9>  gen_udp:send(U,<<1,2,3>>).
> >>ok
> >>10>  gen_udp:send(U,<<1,2,3>>).
> >>{error,econnrefused}
> >>11>  gen_udp:send(U,<<1,2,3>>).
> >>ok
> >>12>  gen_udp:send(U,<<1,2,3>>).
> >>{error,econnrefused}
> >>13>  gen_udp:send(U,<<1,2,3>>).
> >>ok
> >>14>  gen_udp:send(U,<<1,2,3>>).
> >>{error,econnrefused}
> >>
> >>I.e. the error is detected, but only on a subsequent send() (which
> >>doesn't actually send anything).
> >>
> >>     
> >Cool!
> >send is failing on subsequent send, but recv is not ???? This is strange 
> >times.
> >Do you think this behavior is documented anywhere?
> >A small C program may clear this issue for us ?
> >
> >/Tony
> >
> >A small comment intended for the list readers that do understand what we 
> >are talking about.
> >
> >When running the inet_res:resolve function (and friends) it will never 
> >return {error,econnrefused}
> >But the result {error,timeout} even before the timeout value. This may be 
> >a bug or not, for now it is "historical reasons" and
> >"convenient". The reasons is that one or several name severs may get 
> >econnrefused while others may timeout.
> >To get the {error, econnrefused} speed things up when trying servers where 
> >DNS servers may have crashed.
> >But in the general case, server may be down/burned, routers is 
> >down/corrupt, this will not help since no one will send
> >the ICMP reply message on the network.
> >
> >Example:
> >
> >inet_res:resolve("www.rogvall.se", in, a, 
> >[{nameservers,[{{127,0,0,1},53}]},verbose], 5000).
> >Query: {msg,[{header,{header,[{id,7},
> >                               {qr,0},
> >                               {opcode,'query'},
> >                               {aa,0},
> >                               {tc,0},
> >                               {rd,true},
> >                               {ra,0},
> >                               {pr,0},
> >                               {rcode,0}]}},
> >              {qdlist,[{dns_query,[{domain,"www.rogvall.se"},
> >                                   {type,a},
> >                                   {class,in}]}]},
> >              {anlist,[]},
> >              {nslist,[]},
> >              {arlist,[]}]}
> >Try UDP server : {127,0,0,1}:53 (timeout=666)
> >UDP server error: {error,econnrefused}
> >{error,timeout}
> >
> >Trying a host that do not exist:
> >
> >inet_res:resolve("www.rogvall.se", in, a, 
> >[{nameservers,[{{127,0,0,2},53}]},verbose], 5000).
> >Query: {msg,[{header,{header,[{id,8},
> >                               {qr,0},
> >                               {opcode,'query'},
> >                               {aa,0},
> >                               {tc,0},
> >                               {rd,true},
> >                               {ra,0},
> >                               {pr,0},
> >                               {rcode,0}]}},
> >              {qdlist,[{dns_query,[{domain,"www.rogvall.se"},
> >                                   {type,a},
> >                                   {class,in}]}]},
> >              {anlist,[]},
> >              {nslist,[]},
> >              {arlist,[]}]}
> >Try UDP server : {127,0,0,2}:53 (timeout=666)
> >UDP server error: {error,timeout}
> >Try UDP server : {127,0,0,2}:53 (timeout=1333)
> >UDP server error: {error,timeout}
> >Try UDP server : {127,0,0,2}:53 (timeout=2666)
> >UDP server error: {error,timeout}
> >{error,timeout}
> >
> >
> >
> >
> >
> >/Tony
> >
> >
> >________________________________________________________________
> >erlang-questions (at) erlang.org mailing list.
> >See http://www.erlang.org/faq.html
> >To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
> >
> >
> >   
> 
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB


More information about the erlang-questions mailing list