These additional functions for manipulating Internet addresses are declared in the header file `arpa/inet.h'. They represent Internet addresses in network byte order, and network numbers and local-address-within-network numbers in host byte order. See section Byte Order Conversion, for an explanation of network and host byte order.
struct in_addr
that addr points to.
inet_aton
returns nonzero if the address is valid, zero if not.
inet_addr
returns INADDR_NONE
. This is an
obsolete interface to inet_aton
, described immediately above. It
is obsolete because INADDR_NONE
is a valid address
(255.255.255.255), and inet_aton
provides a cleaner way to
indicate error return.
inet_network
returns
-1
.
The function works only with traditional IPv4 class A, B and C network types. It doesn't work with classless addresses and shouldn't be used anymore.
In multi-threaded programs each thread has an own statically-allocated
buffer. But still subsequent calls of inet_ntoa
in the same
thread will overwrite the result of the last call.
Instead of inet_ntoa
the newer function inet_ntop
which is
described below should be used since it handles both IPv4 and IPv6
addresses.
The function works only with traditional IPv4 class A, B and C network types. It doesn't work with classless addresses and shouldn't be used anymore.
The function works only with traditional IPv4 class A, B and C network types. It doesn't work with classless addresses and shouldn't be used anymore.
AF_INET
or AF_INET6
, as appropriate for the type of
address being converted. cp is a pointer to the input string, and
buf is a pointer to a buffer for the result. It is the caller's
responsibility to make sure the buffer is large enough.
AF_INET
or AF_INET6
, as appropriate. cp is a
pointer to the address to be converted. buf should be a pointer
to a buffer to hold the result, and len is the length of this
buffer. The return value from the function will be this buffer address.
Go to the first, previous, next, last section, table of contents.