net
Module
Module Summary
Since
Description
This module provides an API for the network interface.
There is currently no support for Windows.
The content of this file is only valid if the system has been built with 'socket' (esock) support, which is the default.
Data Types
#{name := string(),
flags := [ifaddrs_flag()],
addr := socket:sockaddr(),
netmask := socket:sockaddr(),
broadaddr := socket:sockaddr(),
dstaddr := socket:sockaddr()}
This type defines all addresses (and flags) associated with the interface.
Not all fields of this map has to be present. The flags field can be used to test for some of the fields. For example broadaddr will only be present if the broadcast flag is present in flags.
up | broadcast | debug | loopback | pointopoint | notrailers |
running | noarp | promisc | master | slave | multicast |
portsel | automedia | dynamic
all | default | inet | inet6 | packet |
ifaddrs_filter_map() |
ifaddrs_filter_fun()
- all
- All interfaces
- default
- Interfaces with address family inet and inet6
- inet | inet6 | packet
- Interfaces with only the specified address family
#{family := default | inet | inet6 | packet | all,
flags := any | [ifaddrs_flag()]}
The family field can only have the (above) specified values (and not all the values of socket:domain()).
The use of the flags field is that any flag provided must exist for the interface.
For example, if family is set to inet and flags to [broadcast, multicast] only interfaces with address family inet and the flags broadcast and multicast will be listed.
For each ifaddrs entry, return either true to keep the entry or false to discard the entry.
For example, to get an interface list which only contains non-loopback inet interfaces:
net:getifaddrs(fun(#{addr := #{family := inet}, flags := Flags}) -> not lists:member(loopback, Flags); (_) -> false end).
Exports
OTP 22.0 |
Types
Returns the name of the current host.
OTP 22.0 |
OTP 22.0 |
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.
OTP 22.0 |
OTP 22.0 |
OTP 22.0 |
OTP 22.0 |
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.
OTP 23.0 |
OTP 23.0 |
OTP 23.0 |
OTP 23.0 |
Types
Get interface addresses.
This function is used to get the machines interface addresses, possibly filtered according to Filter.
By default, a filter with the content: #{family => default, flags => any} is used. This will return all interfaces with adresses in the inet and inet6 families.
OTP 22.0 |
Mappings between network interface names and indexes.
OTP 22.0 |
Mappings between network interface index and names.
OTP 22.0 |
Types
Get network interface names and indexes.