Erlang Run-Time System Application (ERTS)

Reference Manual

Version 10.3

Table of Contents

net

Module

net

Module Summary

Network interface.

Since

Module net was introduced in OTP @OTP-14831@.

Description

This module provides an API for the network interface.

Data Types

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

name_info() = #{host := string(), service := string()}
name_info_flag() =
    namereqd | dgram | nofqdn | numerichost | nomericserv

name_info_flag_ext() =
    idn | idna_allow_unassigned | idna_use_std3_ascii_rules

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}
OTP @OTP-14831@
getnameinfo(SockAddr, Flags) -> {ok, Info} | {error, Reason}
OTP @OTP-14831@

Types

Flags = name_info_flags() | undefined
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}
OTP @OTP-14831@
getaddrinfo(Host, Service :: undefined) ->
               {ok, Info} | {error, Reason}
OTP @OTP-14831@
getaddrinfo(Host :: undefined, Service) ->
               {ok, Info} | {error, Reason}
OTP @OTP-14831@
getaddrinfo(Host, Service) -> {ok, Info} | {error, Reason}
OTP @OTP-14831@

Types

Host = Service = string()
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}
OTP @OTP-14831@

Types

Reason = term()

Mappings between network interface names and indexes.

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

Types

Reason = term()

Mappings between network interface index and names.

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

Types

Names = [{Idx, If}]
Reason = term()

Get network interface names and indexes.