1GETNAMEINFO(3) BSD Library Functions Manual GETNAMEINFO(3)
2
4 getnameinfo — address-to-name translation in protocol-independent manner
5
7 #include <sys/socket.h>
8 #include <netdb.h>
9
10 int
11 getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host,
12 size_t hostlen, char *serv, size_t servlen, int flags);
13
15 The getnameinfo() function is defined for protocol-independent address-
16 to-nodename translation. It performs functionality of gethostbyaddr(3)
17 and getservbyport(3) in more sophisticated manner.
18
19 The sa arguement is a pointer to a generic socket address structure of
20 size salen. The arguements host and serv are pointers to buffers to hold
21 the return values. Their sizes are specified by hostlen and servlen
22 repectively. Either host or serv may be NULL if the hostname or service
23 name is not required.
24
25 The flags arguement modifies the behaviour of getnameinfo() as follows:
26
27 If NI_NOFQDN is set only the unqualified hostname is returned for local
28 fully qualified names.
29
30 If NI_NUMERICHOST is set then the numeric form of the hostname is
31 returned.
32
33 If NI_NAMEREQD is set, then a error is returned if the hostname cannot be
34 looked up.
35
36 If NI_NUMERICSERV is set then the service is returned in numeric form.
37
38 If NI_DGRAM is set then the service is UDP based rather than TCP based.
39
41 getaddrinfo(3), gethostbyaddr(3), getservbyport(3), hosts(5),
42 services(5), hostname(7),
43
44 R. Gilligan, S. Thomson, J. Bound, and W. Stevens, ``Basic Socket Inter‐
45 face Extensions for IPv6,'' RFC2133, April 1997.
46
48 The getaddrinfo() function is defined IEEE POSIX 1003.1g draft specifica‐
49 tion, and documented in ``Basic Socket Interface Extensions for IPv6''
50 (RFC2133).
51
52 January 11, 1999