inet ntop

Jump to: navigation, search

Table of Contents >> IPv6 Programmer's Reference


#include <trsocket.h>


const char * inet_ntop (
int af,
const void * src,
char * dst,
int size
);


Function Description

This function supports both IPv4 and IPv6. Refer to [RFC 2553]. Converts an IP address from the binary format to the standard text presentation format.


Parameters

  • af
    address family of the IP address specified by src. This is either AF_INET (IPv4) or AF_INET6 (IPv6).
  • src
    Points to the IP address in binary format.
  • dst
    Points to a buffer where the function will store the resulting text string.
  • size
    Size (in bytes) of the buffer pointed to by dst. For IPv6 addresses, the buffer must be at least 46-bytes (i.e. INET6_ADDRSTRLEN). For IPv4 addresses, the buffer must be at least 16-bytes (i.e. INET_ADDRSTRLEN).


Returns

  • NULL
    Failed. Call tfGetSocketError() for the specific error code.
  • != NULL
    Pointer to the converted IP address in standard text presentation format.


If inet_ntop fails, the error code can be retrieved with tfGetSocketError() which will return one of the following:

  • TM_EAFNOSUPPORT
    af was set to an invalid value for address family; valid values are AF_INET and AF_INET6.
  • TM_ENOSPC
    The size of the result buffer (i.e. size) is inadequate.


Table of Contents >> IPv6 Programmer's Reference