net

Network interface.

This module provides an API for the network interface.

Note!

There is currently no support for Windows.

Types


address_info() =
            #{family := socket:domain(),
              socktype := socket:type(),
              protocol := socket:protocol(),
              address := socket:sockaddr()}

name_info() = #{host := string(), service := string()}

name_info_flags() = [name_info_flag() | name_info_flag_ext()]

name_info_flag() =
            namereqd | dgram | nofqdn | numerichost | nomericserv

name_info_flag_ext() =
            idn | idna_allow_unassigned | idna_use_std3_ascii_rules

network_interface_name() = string()

network_interface_index() = integer() >= 0

Functions


gethostname() -> {ok, HostName} | {error, Reason}

  • HostName = string()
  • Reason = term()

Returns the name of the current host.

getnameinfo(SockAddr) -> {ok, Info} | {error, Reason}

getnameinfo(SockAddr, Flags) -> {ok, Info} | {error, Reason}

Address-to-name translation in a protocol-independant manner.

This function is the inverse of getaddrinfo. It converts a socket address to a corresponding host and service.

getaddrinfo(Host) -> {ok, Info} | {error, Reason}

Network address and service translation.

This function is the inverse of getnameinfo. It converts host and service to a corresponding socket address.

One of the Host and Service may be undefined but not both.

if_name2index(Name) -> {ok, Idx} | {error, Reason}

Mappings between network interface names and indexes.

if_index2name(Idx) -> {ok, Name} | {error, Reason}

Mappings between network interface index and names.

if_names() -> Names | {error, Reason}

Get network interface names and indexes.