inet(3N)inet(3N)NAME
inet: inet_addr(), inet_lnaof(), inet_makeaddr(), inet_netof(),
inet_network(), inet_ntoa(), inet_ntoa_r() - Internet address manipula‐
tion routines
SYNOPSIS
Remarks
The routine is described in the section below.
DESCRIPTION
Interpret character strings representing numbers
expressed in the Internet standard "dot" notation.
returns numbers suitable for use as Internet
addresses.
returns numbers suitable for use as Internet net‐
work numbers.
Return values can be assigned to a (defined in by
using a technique similar to the following:
Take an Internet address and return an
ASCII string representing the address in dot nota‐
tion.
Take an Internet network number and a local network address
and construct an Internet address from it.
Break apart Internet host addresses,
returning the network number part.
Break apart Internet host addresses,
returning the local network address part.
All Internet addresses are returned in network order (bytes ordered
from left to right). All network numbers and local address parts are
returned as machine-format integer values. Bytes in HP-UX systems are
ordered from left to right.
Internet Addresses
Values specified using dot notation take one of the following forms:
When four parts are specified, each is interpreted as a byte of data
and assigned, from left to right, to the four bytes of an Internet
address.
When a three-part address is specified, the last part is interpreted as
a 16-bit quantity and placed in the right-most two bytes of the network
address. This makes the three-part address format convenient for spec‐
ifying Class B network addresses, as in
When a two-part address is supplied, the last part is interpreted as a
24-bit quantity and placed in the right-most three bytes of the network
address. This makes the two-part address format convenient for speci‐
fying Class A network addresses as in
When only one part is given, the value is stored directly in the net‐
work address without any byte rearrangement.
All numbers supplied as parts in dot notation can be decimal, octal, or
hexadecimal, as specified in the C language (i.e., a leading 0x or 0X
implies hexadecimal; a leading 0 implies octal; otherwise, the number
is interpreted as decimal).
In a multithreaded application, uses thread-specific storage that is
re-used in each call. The return value, the character string, should
be unique for each thread and should be saved, if desired, before the
thread makes the next call.
Obsolescent Interfaces
The following reentrant interface has been moved from to
It is included to support existing applications and may be removed in a
future release. New multithreaded applications should use the regular
API (those without the suffix.)
The reentrant interface functions the same as the regular interface
without the suffix. However, expects to be passed the address of a
character buffer and will store the result at the supplied location.
If the buffer is of insufficient length, is returned. If the operation
is successful, the length of the result string (not including the ter‐
minating null character) is returned.
RETURN VALUE
The routines return values as described in the section. and return for
malformed requests.
WARNINGS
The return value from the function cannot distinguish between a failure
(and a local broadcast address (255.255.255.255). This can be handled
by using the function instead of the function.
AUTHOR
The routines were developed by the University of California, Berkeley.
SEE ALSOgethostent(3N), getnetent(3N), inet6(3N), hosts(4), networks(4),
thread_safety(5).
inet(3N)