Skip to content

Commit ab68539

Browse files
Merge pull request #10981 from AndreaBruzz/patch-1
kernel: Document `inet:gethostbyname/3`, `inet:gethostbyaddr/2`, `inet:getaddr/3`, and `inet:getaddrs/3`.
2 parents bb19914 + b8f41e1 commit ab68539

1 file changed

Lines changed: 45 additions & 37 deletions

File tree

lib/kernel/src/inet.erl

Lines changed: 45 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2555,15 +2555,7 @@ gethostbyname(Name) ->
25552555
gethostbyname_tm(Name, inet, false)
25562556
end.
25572557

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

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

26052607

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

26162613
gethostbyaddr(Address) ->
26172614
gethostbyaddr_tm(Address, false).
26182615

2619-
-doc false.
2616+
-doc """
2617+
Resolve (reverse) an address to a [`#hostent{}`](`t:hostent/0`) record.
2618+
2619+
Returns a [`#hostent{}`](`t:hostent/0`) record for the host
2620+
with the specified address.
2621+
2622+
`Timeout` specifies a time-out in milliseconds, or the atom `infinity`.
2623+
""".
26202624
-spec gethostbyaddr(Address :: string() | ip_address(),
26212625
Timeout :: non_neg_integer() | 'infinity') ->
26222626
{'ok', #hostent{}} | {'error', posix()}.
@@ -2805,13 +2809,7 @@ getfd(Socket) ->
28052809
%% Lookup an ip address
28062810
%%
28072811

2808-
-doc """
2809-
Resolve a host to an address, in a specific addresss family.
2810-
2811-
Returns the [IP address](`t:ip_address/0`) for `Host` as a tuple of integers.
2812-
`Host` can be an [IP address](`t:ip_address/0`), a single `t:hostname/0`,
2813-
or a fully qualified `t:hostname/0`.
2814-
""".
2812+
-doc(#{equiv => getaddr(Host, Family, infinity)}).
28152813
-spec getaddr(Host, Family) -> {ok, Address} | {error, posix()} when
28162814
Host :: ip_address() | hostname(),
28172815
Family :: address_family(),
@@ -2820,11 +2818,19 @@ or a fully qualified `t:hostname/0`.
28202818
getaddr(Address, Family) ->
28212819
getaddr(Address, Family, infinity).
28222820

2823-
-doc false.
2821+
-doc """
2822+
Resolve a host to an address, in a specific address family.
2823+
2824+
Returns the [IP address](`t:ip_address/0`) for `Host` as a tuple of integers.
2825+
`Host` can be an [IP address](`t:ip_address/0`), a single `t:hostname/0`,
2826+
or a fully qualified `t:hostname/0`.
2827+
2828+
`Timeout` specifies a time-out in milliseconds, or the atom `infinity`.
2829+
""".
28242830
-spec getaddr(Host :: ip_address() | hostname(),
2825-
Family :: address_family(),
2826-
Timeout :: non_neg_integer() | 'infinity') ->
2827-
{'ok', ip_address()} | {'error', posix()}.
2831+
Family :: address_family(),
2832+
Timeout :: non_neg_integer() | 'infinity') ->
2833+
{'ok', ip_address()} | {'error', posix()}.
28282834

28292835
getaddr(Address, Family, Timeout) ->
28302836
%% ?DBG([{address, Address}, {family, Family}, {timeout, Timeout}]),
@@ -2846,13 +2852,7 @@ getaddr_tm(Address, Family, Timer) ->
28462852
Error
28472853
end.
28482854

2849-
-doc """
2850-
Resolve a host to a list of addresses, in a specific address family.
2851-
2852-
Returns a list of all IP addresses for `Host`.
2853-
`Host` can be an [IP address](`t:ip_address/0`),
2854-
a single `t:hostname/0`, or a fully qualified `t:hostname/0`.
2855-
""".
2855+
-doc(#{equiv => getaddrs(Host, Family, infinity)}).
28562856
-spec getaddrs(Host, Family) ->
28572857
{ok, Addresses} | {error, posix()} when
28582858
Host :: ip_address() | hostname(),
@@ -2862,8 +2862,16 @@ a single `t:hostname/0`, or a fully qualified `t:hostname/0`.
28622862
getaddrs(Address, Family) ->
28632863
getaddrs(Address, Family, infinity).
28642864

2865-
-doc false.
2866-
-spec getaddrs(Host :: ip_address() | string() | atom(),
2865+
-doc """
2866+
Resolve a host to a list of addresses, in a specific address family.
2867+
2868+
Returns a list of all IP addresses for `Host`.
2869+
`Host` can be an [IP address](`t:ip_address/0`),
2870+
a single `t:hostname/0`, or a fully qualified `t:hostname/0`.
2871+
2872+
`Timeout` specifies a time-out in milliseconds, or the atom `infinity`.
2873+
""".
2874+
-spec getaddrs(Host :: ip_address() | hostname(),
28672875
Family :: address_family(),
28682876
Timeout :: non_neg_integer() | 'infinity') ->
28692877
{'ok', [ip_address()]} | {'error', posix()}.

0 commit comments

Comments
 (0)