TCP/IP Programming Manual

Usage Guidelines
By default, this function returns the hostname’s fully qualified domain name.
This function, along with getipnodebyaddr, are protocol-independent replacements for
gethostbyaddr, host_file_gethostbyaddr. getnameinfo provides extra functionality beyond
what getipnodebyaddr provides because it handles both the host’s address and port number.
Appropriate use of this function can eliminate calls to getservbyport and at the same time
provide protocol independence.
Example
The following programming example calls the getnameinfo routine to get a hostname’s fully
qualified domain name.
#include <socket.h>
#include <netdb.h>
{
...
error = getnameinfo((struct sockaddr *)sin,
addrlen,hname,sizeof(hname), sname,
sizeof(sname),NI_NUMERICHOST|NI_NUMERICSERV);
if(error)
fprintf(stderr, "getnameinfo: %s\n", gai_strerror(error));
}
Errors
Upon successful completion, this function returns 0 (zero) and the requested values are stored in
the buffers specified for the call. Otherwise, the value returned is nonzero and errno is set to
indicate the error (only when the error is EAI_SYSTEM). See the error codes described in ecode
.
getnetbyaddr
The getnetbyaddr function gets the name of the network corresponding to the specified network
address.
C Synopsis
#include <socket.h>
#include <netdb.h>
net_entry_ptr = getnetbyaddr (net_addr, type);
struct netent *net_entry_ptr;
unsigned long net_addr;
int type;
TAL Synopsis
?NOLIST, SOURCE SOCKDEFT
?NOLIST, SOURCE SOCKPROC
net_entry_ptr := getnetbyaddr (net_addr, type);
INT(32) net_entry_ptr;
INT(32) type;
getnetbyaddr 119