net(3)

NAME
net - Network interface.

DESCRIPTION

This module provides an API for the network interface.

    Note:
There is currently no support for Windows.

DATA 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

EXPORTS

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

    Types:
        HostName = string()
        Reason = term()

    Returns the name of the current host.

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

    Types:
        SockAddr = socket:sockaddr()
        Flags = name_info_flags() | undefined
        Info = name_info()
        Reason = term()

    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}
getaddrinfo(Host, Service :: undefined) ->
               {ok, Info} | {error, Reason}
getaddrinfo(Host :: undefined, Service) ->
               {ok, Info} | {error, Reason}
getaddrinfo(Host, Service) -> {ok, Info} | {error, Reason}

    Types:
        Host = Service = string()
        Info = [address_info()]
        Reason = term()

    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}

    Types:
        Name = network_interface_name()
        Idx = network_interface_index()
        Reason = term()

    Mappings between network interface names and indexes.

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

    Types:
        Idx = network_interface_index()
        Name = network_interface_name()
        Reason = term()

    Mappings between network interface index and names.

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

    Types:
        Names = [{Idx, If}]
        Idx = network_interface_index()
        If = network_interface_name()
        Reason = term()

    Get network interface names and indexes.