Search code examples
network-programmingerlangiphostname

Erlang: get ip address from hostname


In my local network exists pcs, where have a hostname as example "testhost". How can I from given hostname get a IP-address ?

I tried:

net_adm:dns_hostname("testhost.fritz.box").

Result:

{ok,"testhost.fritz.box"}

I need a function which give me IP-Address from hostname.

Thx


Solution

  • According to http://erlang.org/doc/man/inet.html#getaddr-2 it seems you should be able to use getaddr like:

    inet:getaddr("testhost.fritz.box", inet)