Socket. Host
(sockets v2.1.7)
Copy Markdown
Looks up information about a host by name or IP address.
Given a hostname like "google.com" or an IP address, it returns a struct
with the canonical name, any known aliases, and the list of IP addresses
associated with that host. Also exposes helpers for getting the local
machine's hostname and network interfaces.
Summary
Functions
Get the hostent by address.
Get the hostent by address, raising if an error occurs.
Get the hostent by name.
Get the hostent by name and family.
Get the hostent by name, raising if an error occurs.
Get the hostent by name and family, raising if an error occurs.
Get the interfaces of the machine.
Get the interfaces of the machine, raising if an error occurs.
Get the hostname of the machine.
Types
Functions
@spec by_address(Socket.Address.t()) :: {:ok, t()} | {:error, :inet.posix()}
Get the hostent by address.
@spec by_address!(Socket.Address.t()) :: t()
Get the hostent by address, raising if an error occurs.
@spec by_name(binary()) :: {:ok, t()} | {:error, :inet.posix()}
Get the hostent by name.
@spec by_name(binary(), :inet.address_family()) :: {:ok, t()} | {:error, :inet.posix()}
Get the hostent by name and family.
Get the hostent by name, raising if an error occurs.
@spec by_name!(binary(), :inet.address_family()) :: t()
Get the hostent by name and family, raising if an error occurs.
@spec interfaces() :: {:ok, [tuple()]} | {:error, :inet.posix()}
Get the interfaces of the machine.
@spec interfaces!() :: [tuple()]
Get the interfaces of the machine, raising if an error occurs.
@spec name() :: String.t()
Get the hostname of the machine.