TCP/IP Programming Manual
struct sockaddr_in sin;
struct hostent *hp;
...
if ((hp = getipnodebyname (nameptr, AF_INET, AI_PASSIVE,
&error_num)) != (struct hostent *)
NULL) {
memmove ((char *)&sin.sin_addr.s_addr,
(char *)hp -> h_addr,
(size_t) hp -> h_length );
} ...
Usage Guidelines
• The getipnodebyname function searches host entries sequentially until a match with the
name argument occurs.
• The geipnodebyname function returns a pointer to a structure of type hostent whose
members specify data obtained from a name server specified in the RESCONF file or from
fields of a record line in the network hostname database file.
• getipnodebyname provides the same functionality as gethostbyname,
host_file_gethostbyname but is protocol-independent.
• A thread-safe environment must be used with the getipnodebyname function.
Errors
An unsuccessful function returns a pointer (error_ptr) to one of the following values:
The specified name is not a valid hostname or alias.HOST_NOT_FOUND
The server recognized the request and the name specified but no address is available.NO_ADDRESS
A server failure occurred. This is a nonrecoverable error.NO_RECOVERY
An error occurred that might have been caused by a transient condition. A later retry might
succeed.
TRY_AGAIN
getnameinfo
The getnameinfo function translates a protocol-independent host address to hostname. This
function uses a socket address to search for a hostname and service name. Given a binary IPv4
or IPv6 address and port number, this function returns the corresponding hostname and service
name from a name resolution service. (This function is supported for NonStop TCP/IPv6 only.)
NOTE: The C synopsis is given in ANSI C format rather than the pre-ANSI C formats of the other
library routines because the only NonStop servers you can use these routines on all support ANSI
C. (ANSI C format defines the function and the arguments in the same line rather than using an
assign statement and defining the arguments underneath.)
C Synopsis
#include <netdb.h>
int getnameinfo(const struct sockaddr *sa,socklen_t salen,char
*host,socklen_t hostlen,char *serv,socklen_t servlen,int flags);
TAL Synopsis
?NOLIST, SOURCE SOCKDEFT
?NOLIST, SOURCE SOCKPROC
error := getnameinfo(sa, salen, host, hostlen, serv, servlen, flags);
INT(32) error;
getnameinfo 117