Here is what I am trying:
send() ->
{ok,S} = gen_udp:open(5353,[{reuseaddr,true}, {ip,{224,0,0,251}},
{multicast_ttl,4}, {multicast_loop,false}, {broadcast,true}, binary]),
{ok,P} =
inet_dns:encode(#dns_query{domain="_daap._tcp.local",type=ptr,class=in}),
gen_udp:send(S,{224,0,0,251},5353,P),
gen_udp:close(S).
Here is what I am getting in the console when I call :send()
24> test:send().
** exception error: {badrecord,dns_rec}
in function inet_dns:encode/1
in call from test:send/0
25>
If I can get over this hump I will have a basic implementation done.
Anyone have any ideas?
> 24> test:send().
> ** exception error: {badrecord,dns_rec}
> in function inet_dns:encode/1
> in call from test:send/0
You're passing a dns_query record to inet_dns:encode/1, but it expects a
dns_rec record. (If I knew the DNS protocol by heart, I'd tell you how
to build one, but for now I'll have to refer to inet_dns.hrl.)
--
Magnus Henoch, mag...@erlang-consulting.com
Erlang Training and Consulting
http://www.erlang-consulting.com/
________________________________________________________________
erlang-questions mailing list. See http://www.erlang.org/faq.html
erlang-questions (at) erlang.org
Maybe try adding
-include_lib("kernel/src/inet_dns.hrl").
or something? It looks like you're missing the definition of the dns_rec
record.
Andrew
send(Domain) ->
{ok,S} = gen_udp:open(5353,[{reuseaddr,true}, {ip,{224,0,0,251}},
{multicast_ttl,4}, {multicast_loop,false}, {broadcast,true}, binary]),
P =
#dns_rec{header=#dns_header{},qdlist=[#dns_query{domain=Domain,type=ptr,class=
in}]},
gen_udp:send(S,{224,0,0,251},5353,inet_dns:encode(P)),
gen_udp:close(S).