erlangerlang-ports

inet_addr functionality in erlang


As the question says, is there any function or module that performs the functionality of inet_addr ?

Results from google isnt suggesting any direct way or am i missing something ?

Thanks.


Solution

  • You can use inet_parse:address, and then convert the resuting list to binary. e.g.

    16> list_to_binary(tuple_to_list(element(2,inet_parse:address("192.168.42.2")))).
    

    <<192,168,42,2>>