Again, behaviour of getnameinfo can be modified by setting several bit-ORed flags in the last argument:
NI_NOFQDN
If you try to resolve, inside the *sa argument, an IP address to a domain name and this name is in the same domain as the local host, only the host name – without the domain – is returned. Otherwise a fully qualified domain name is returned. For hosts in external domains, this flag has no impact.
NI_NUMERICHOST
With this flag on, getnameinfo() will set *node to a string representing an IP address. To an IPv6 address, a zone identifier may also be appended as described [RFC4007], for example“fe80::1%eth0”.
NI_NUMERICSCOPE
If this flag is set together with the previous one, the zone within an address scope will be expressed as a zone index (for example, an interface index) instead of a symbolic zone identifier(e.g., eth0).
NI_NUMERICSERV
Similarly, with this flag on, the *service string will be filled with a decimal port number instead of a symbolic service name, for example “80” instead of “www”.
NI_NAMEREQD
If this flag is set and no domain name can be found for the IP address in *sa, getnameinfo will return a non-zero error code, instead of just copying the IP address into *node.
NI_DGRAM
This flag indicates a connectionless service (SOCK_DGRAM). By default, a connectionoriented service (SOCK_DGRAM) is assumed.
