inet_ntop (3p) - Linux Manuals
inet_ntop: convert IPv4 and IPv6 addresses between binary
PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.NAME
inet_ntop, inet_pton - convert IPv4 and IPv6 addresses between binary and text form
SYNOPSIS
#include <arpa/inet.h>
const char *inet_ntop(int af, const void *restrict
src,
int inet_pton(int af, const char *restrict src,
void *restrict dst);
DESCRIPTION
The inet_ntop() function shall convert a numeric address into
a text string suitable for presentation. The af
argument shall specify the family of the address. This can be AF_INET
The inet_pton() function shall convert an address in its standard
text presentation form into its numeric binary form.
The af argument shall specify the family of the address. The
AF_INET and AF_INET6
address families shall be supported. The src argument points
to the string being passed in. The dst argument points to a
buffer into which the function stores the numeric address; this
shall be large enough to hold the numeric address (32 bits for AF_INET,
If the af argument of inet_pton() is AF_INET, the src
string shall be in the standard IPv4 dotted-decimal
form:
where "ddd" is a one to three digit decimal number between 0
and 255 (see inet_addr()). The inet_pton() function does
not accept other formats (such as the octal
numbers, hexadecimal numbers, and fewer than four numbers that inet_addr()
accepts).
If the af argument of inet_pton() is AF_INET6, the src
string shall be in one of the following standard IPv6
text forms:
The inet_ntop() function shall return a pointer to the buffer
containing the text string if the conversion succeeds, and
NULL otherwise, and set errno to indicate the error.
The inet_pton() function shall return 1 if the conversion succeeds,
with the address pointed to by dst in network
byte order. It shall return 0 if the input is not a valid IPv4 dotted-decimal
string or a valid
IPv6 address string, or -1 with errno set to [EAFNOSUPPORT]
if the af argument is unknown.
The inet_ntop() and inet_pton() functions shall fail if:
The af argument is invalid.
The following sections are informative.
ddd.ddd.ddd.ddd
RETURN VALUE
ERRORS
EXAMPLES
APPLICATION USAGE
RATIONALE
FUTURE DIRECTIONS
COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .