Skip to content

Commit b8f41e1

Browse files
authored
kernel: document inet:gethostbyname/3, gethostbyaddr/2 and getaddrs/3
Move the prose documentation to the timeout variants and mark the shorter convenience functions as equivalent, matching the getaddr/3 documentation. Also document the Timeout argument and align the getaddrs/3 Host type with getaddrs/2.
1 parent 7f2dc0c commit b8f41e1

1 file changed

Lines changed: 32 additions & 26 deletions

File tree

lib/kernel/src/inet.erl

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2553,15 +2553,7 @@ gethostbyname(Name) ->
25532553
gethostbyname_tm(Name, inet, false)
25542554
end.
25552555

2556-
-doc """
2557-
Resolve a hostname to a [`#hostent{}`](`t:hostent/0`) record,
2558-
in a specific address family.
2559-
2560-
Returns a [`#hostent{}`](`t:hostent/0`) record for the host
2561-
with the specified `Hostname`, restricted to the specified address `Family`.
2562-
2563-
See also `gethostbyname/1`.
2564-
""".
2556+
-doc(#{equiv => gethostbyname(Hostname, Family, infinity)}).
25652557
-spec gethostbyname(Hostname, Family) ->
25662558
{ok, Hostent} | {error, posix()} when
25672559
Hostname :: hostname(),
@@ -2571,7 +2563,17 @@ See also `gethostbyname/1`.
25712563
gethostbyname(Name, Family) ->
25722564
gethostbyname_tm(Name, Family, false).
25732565

2574-
-doc false.
2566+
-doc """
2567+
Resolve a hostname to a [`#hostent{}`](`t:hostent/0`) record,
2568+
in a specific address family.
2569+
2570+
Returns a [`#hostent{}`](`t:hostent/0`) record for the host
2571+
with the specified `Name`, restricted to the specified address `Family`.
2572+
2573+
`Timeout` specifies a time-out in milliseconds, or the atom `infinity`.
2574+
2575+
See also `gethostbyname/1`.
2576+
""".
25752577
-spec gethostbyname(Name :: hostname(),
25762578
Family :: address_family(),
25772579
Timeout :: non_neg_integer() | 'infinity') ->
@@ -2601,20 +2603,22 @@ gethostbyname_tm(Name, Family, Timer) ->
26012603
gethostbyname_tm(Name, Family, Timer, Opts).
26022604

26032605

2604-
-doc """
2605-
Resolve (reverse) an address to a [`#hostent{}`](`t:hostent/0`) record.
2606-
2607-
Returns a [`#hostent{}`](`t:hostent/0`) record for the host
2608-
with the specified address.
2609-
""".
2606+
-doc(#{equiv => gethostbyaddr(Address, infinity)}).
26102607
-spec gethostbyaddr(Address) -> {ok, Hostent} | {error, posix()} when
26112608
Address :: string() | ip_address(),
26122609
Hostent :: hostent().
26132610

26142611
gethostbyaddr(Address) ->
26152612
gethostbyaddr_tm(Address, false).
26162613

2617-
-doc false.
2614+
-doc """
2615+
Resolve (reverse) an address to a [`#hostent{}`](`t:hostent/0`) record.
2616+
2617+
Returns a [`#hostent{}`](`t:hostent/0`) record for the host
2618+
with the specified address.
2619+
2620+
`Timeout` specifies a time-out in milliseconds, or the atom `infinity`.
2621+
""".
26182622
-spec gethostbyaddr(Address :: string() | ip_address(),
26192623
Timeout :: non_neg_integer() | 'infinity') ->
26202624
{'ok', #hostent{}} | {'error', posix()}.
@@ -2835,13 +2839,7 @@ getaddr_tm(Address, Family, Timer) ->
28352839
Error
28362840
end.
28372841

2838-
-doc """
2839-
Resolve a host to a list of addresses, in a specific address family.
2840-
2841-
Returns a list of all IP addresses for `Host`.
2842-
`Host` can be an [IP address](`t:ip_address/0`),
2843-
a single `t:hostname/0`, or a fully qualified `t:hostname/0`.
2844-
""".
2842+
-doc(#{equiv => getaddrs(Host, Family, infinity)}).
28452843
-spec getaddrs(Host, Family) ->
28462844
{ok, Addresses} | {error, posix()} when
28472845
Host :: ip_address() | hostname(),
@@ -2851,8 +2849,16 @@ a single `t:hostname/0`, or a fully qualified `t:hostname/0`.
28512849
getaddrs(Address, Family) ->
28522850
getaddrs(Address, Family, infinity).
28532851

2854-
-doc false.
2855-
-spec getaddrs(Host :: ip_address() | string() | atom(),
2852+
-doc """
2853+
Resolve a host to a list of addresses, in a specific address family.
2854+
2855+
Returns a list of all IP addresses for `Host`.
2856+
`Host` can be an [IP address](`t:ip_address/0`),
2857+
a single `t:hostname/0`, or a fully qualified `t:hostname/0`.
2858+
2859+
`Timeout` specifies a time-out in milliseconds, or the atom `infinity`.
2860+
""".
2861+
-spec getaddrs(Host :: ip_address() | hostname(),
28562862
Family :: address_family(),
28572863
Timeout :: non_neg_integer() | 'infinity') ->
28582864
{'ok', [ip_address()]} | {'error', posix()}.

0 commit comments

Comments
 (0)