inet_ntop

inet_ntop converts an IPv4 or IPv6 Internet network address into a string in Internet standard format. This is the ANSI version of the Windows function InetNtop.

Syntax

PCTSTR WSAAPI inet_ntop(
	INT  Family,
	PVOID pAddr,
	PSTR pStringBuf,
	size_t StringBufSize
);

Parameters

Family [in]

The address family: AF_INET or AF_INET6.

pAddr [in]

A pointer to the IP address in network byte order. It points to an IN_ADDR structure with IPv4 address when Family is AF_INET. It points to IN6_ADDR structure with IPv6 address when Family is AF_IN6.

pStringBuf [out]

A pointer to a buffer to store the NULL-terminated string representation of the IP address.

For IPv4, this buffer should be large enough to hold at least 16 characters.

For IPv6, this buffer should be large enough to hold at least 46 characters.

StringBufSize [in]

The length, in characters, of the buffer pointed to by the pStringBuf parameter.

For IPv4, this buffer should be large enough to hold at least 16 characters.

For IPv6, this buffer should be large enough to hold at least 46 characters.

Return Value

A valid pointer is returned if the function succeeds. It points to a buffer containing the string representation of IP address.

A NULL value is returned if the function fails. A specific error code can be retrieved by calling WSAGetLastError.

Possible error codes returned by WSAGetLastError are:

Error Code Meaning

WSAEAFNOSUPPORT

The address family is not supported.

WSAEFAULT

An invalid parameter was passed to the function.

Requirements

Minimum Supported Version RTX64 2014 with Service Pack 1
Header WS2Tcpip.h, Winsock2.h
Library RtTcpip.lib