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}
SockAddr = socket:sockaddr()
Info = name_info()
Reason = term()
getnameinfo(SockAddr, Flags) -> {ok, Info} | {error, Reason}
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}
Host = 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}
Name = network_interface_name()
Idx = network_interface_index()
Reason = term()
Mappings between network interface names and indexes.
if_index2name(Idx) -> {ok, Name} | {error, Reason}
Idx = network_interface_index()
Name = network_interface_name()
Reason = term()
Mappings between network interface index and names.
if_names() -> Names | {error, Reason}
Names = [{Idx, If}]
Idx = network_interface_index()
If = network_interface_name()
Reason = term()
Get network interface names and indexes.