Bob Ippolito (@etrepum) on Haskell, Python, Erlang, JavaScript, etc.

IP Addresses in Erlang


The Erlang kernel has an undocumented module for dealing with ipv4 and ipv6 internet addresses: inet_parse. I ran across it from a brief mention in the inet documentation while looking for a function to convert an Erlang ip_address() tuple to a string().

inet_parse:address(String) -> {ok, Address} | {error, Reason}

1> inet_parse:address("").
2> inet_parse:address("::1").
3> inet_parse:address("300.400.500.600").

inet_parse:ntoa(Address) -> String

1> inet_parse:ntoa({127,0,0,1}).
2> inet_parse:ntoa({0,0,0,0,0,0,0,1}).