TCP/IP Programming Manual
The NonStop server socket library uses the DEFINE command to resolve the file names and process
names used by the socket library. See Using the DEFINE Command (page 29), for more information
about the DEFINE command.
When a program sends a name-resolution request to the resolver, the resolver tries to send the
query to the servers listed in the RESCONF file, sending the request to the server that has the highest
priority first. The priority of a server depends on its position in the RESCONF file; the server listed
first, called the primary server, has the highest priority. The RESCONF file can contain a
maximum of 16 servers but must contain at least one server.
The resolver sends the request to the primary server using TCP port 53. If the primary name server
does not respond within 4 seconds, the resolver tries to access the secondary name server; if that
server does not respond within 4 seconds, the resolver tries to access the tertiary name server.
If none of the name servers responds within 4 seconds, the resolver retries the primary name server;
however, this time the resolver waits up to 8 seconds for a response. If the primary name server
does not respond within 8 seconds, the resolver tries the secondary name server. If that server does
not respond within 8 seconds, the resolver tries the tertiary name server.
The resolver continues trying to access each name server, increasing the time it waits for a response,
from 4 to 8 to 16 and then to 32 seconds in each of the subsequent retry cycles. Failure conditions
are stored in the external variable h_errno. The errors returned in h_errno are described along
with the gethostbyaddr and gethostbyname functions in Chapter 4 (page 81).
If the name server cannot be accessed (that is, does not respond to requests), the HOSTS-type file
is accessed in an attempt to resolve the name. If the name server can be accessed but cannot
resolve the name, the resolver routine returns an error and the HOSTS-type file is not checked.
NOTE: Beginning with the D40.00 RVU of NonStop TCP/IP, the socket-library routine
gethostbyname() was changed with respect to name server lookups. If the name server cannot
resolve the name, or the name server does not respond, the HOSTS-type file is accessed.
Resolving Names by Using a HOSTS-Type File
If a name server is not available on the network, you can resolve names by using a HOSTS-type
file. This nonstandard technique for resolving names can be implemented using either of two
methods:
• From a program, call one of the following routines:
host_file_gethostbyname◦
◦ host_file_gethostbyaddr
Defining a value for =TCPIP^HOST^FILE is optional for this method. The only reason
for defining a value for =TCPIP^HOST^FILE is to specify a file other than the default
file to resolve names.
• From a program, call one of the following routines:
gethostbyname◦
◦ gethostbyaddr
◦ getaddrinfo (NonStop TCP/IPv6)
◦ getnameinfo (NonStop TCP/IPv6)
With this method, users running the program must define a value for =TCPIP^HOST^FILE
before running the program.
With either method, TCP/IP resolves the names by using either the $SYSTEM.ZTCPIP.HOSTS,
the $SYSTEM.ZTCPIP.IPNODES (for NonStop TCP/IPv6 and CIP) file or a file name specified
28 Introduction to Programming to the Guardian Sockets Library