inet_dns module

Emmanuelle BERNARD <>
Wed Dec 1 23:52:36 CET 1999


Hi,

I would like to use the functions encode and decode of the inet_dns
module
How to use them?


The little program :
""""""""""""""""""""""""""""""""""""""""""""""""""""
-module(i).
-export([test/0]).

  test()->

Var={dns_rec,{dns_header,10,0,0,0,0,1,0,0,0},[{dns_query,"ada.eu.org",a,in}],[],[],[]},

      io:format("~p~n", [Var]),
      Packet=inet_dns:encode(Var),
      io:format("~p~n", [Packet]),
      Result=inet_dns:decode(Packet),
      io:format("~p~n", [Result]).
  """""""""""""""""""""""""""""""""""""""""""""""

returns me:

########################################
3> c(i).
  {ok,i}
  4> i:test().
  {dns_rec,{dns_header,10,0,0,0,0,1,0,0,0},
           [{dns_query,"ada.eu.org",a,in}],
           [],
           [],
           []}

{ok,[0,10,1,0,0,1,0,0,0,0,0,0,3,97,100,97,2,101,117,3,111,114,103,0,0,1,0,1]}

  {error,fmt}
  ok
  ######################################

Why is there a format error?
Should I use binary_to_list(Data) or list_to_binary(Data) anywhere?

Thanks,

Emmanuelle




More information about the erlang-questions mailing list