getnameinfo3bind
Address-to-name translation in protocol-independent manner
Usage
#include <sys/socket.h>
#include <netdb.h>
int
getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags);
Overview
The getnameinfo() function is defined for protocol-independent address-to-nodename translation. It performs functionality of gethostbyaddr(3) and getservbyport(3) in more sophisticated manner.
The sa arguement is a pointer to a generic socket address structure of size salen. The arguements host and serv are pointers to buffers to hold the return values. Their sizes are specified by hostlen and servlen repectively. Either host or serv may be NULL if the hostname or service name is not required.
The flags arguement modifies the behaviour of getnameinfo() as follows:
If NI_NOFQDN is set only the unqualified hostname is returned for local fully qualified names.
If NI_NUMERICHOST is set then the numeric form of the hostname is returned.
If NI_NAMEREQD is set, then a error is returned if the hostname cannot be looked up.
If NI_NUMERICSERV is set then the service is returned in numeric form.
If NI_DGRAM is set then the service is UDP based rather than TCP based.
Releases
4 releases since Debian 2.2 (Potato); the text changed 2 times.