res_init Subroutine

Purpose

Searches for a default domain name and Internet address.

Library

Standard C Library (libc.a)

Syntax

#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
 
void res_init ( )

Description

The res_init subroutine reads the /etc/resolv.conf file for the default domain name and the Internet address of the initial hosts running the name server.

Note: If the /etc/resolv.conf file does not exist, the res_init subroutine attempts name resolution using the local /etc/hosts file. If the system is not using a domain name server, the /etc/resolv.conf file should not exist. The /etc/hosts file should be present on the system even if the system is using a name server. In this instance, the file should contain the host IDs that the system requires to function even if the name server is not functioning.

The res_init subroutine is one of a set of subroutines that form the resolver, a set of functions that translate domain names to Internet addresses. All resolver subroutines use the /usr/include/resolv.h file, which defines the _res structure. The res_init subroutine stores domain name information in the _res structure. Three environment variables, LOCALDOMAIN, RES_TIMEOUT, and RES_RETRY, affect default values related to the _res structure.

All applications containing the res_init subroutine must be compiled with the _BSD macro set to a specific value. Acceptable values are 43 and 44. In addition, all socket applications must include the BSD libbsd.a library.

For more information on the _res structure, see "Understanding Domain Name Resolution" in AIX® Version 7.1 Communications Programming Concepts.

Files

Item Description
                         /etc/resolv.conf Contains the name server and domain name.
                         /etc/hosts Contains host names and their addresses for hosts in a network. This file is used to resolve a host name into an Internet address.