Installing and Administering Internet Services

Chapter 3 127
Configuring and Administering the BIND Name Service
Configuring the Resolver to Set Timeout Values
parameter value is the pointer to the location where the option value is
stored. The sizeof value parameter is used to obtain the number of
bytes required for the variable so that memory can be allocated to that
variable when a function is invoked.
The return value of this function is 0 if the function successfully gets the
value of the field in the value parameter. It will return -1 on failure.
Sample Program With Timeout Values
main()
{
int retrans = 600;
int retry =1;
struct hostent *hp;
struct in_addr ia;
char *name = "localhost";
res_init();
set_resfield(RES_RETRANS, &retrans);
set_resfield(RES_RETRANS, &retry);
hp = gethostbyname (name);
if (hp == NULL )
{
printf ("gethostbyname failed\n");
herror("Error");
}
else
{
int i;
for (i=o; hp->h_addr_list[i]; i++)
{
memcpy((caddre_t)&ia, hep->h_addr_list[i],\
sizeof(ia));
printf("%s", inet_ntoa(ia));
}
}
get_resfield (RES_RETRANS, &retrans, sizeof\
retrans);
get_resfield (RES_RETRY, &retry, sizeof retry);
printf ("retry = %d \n retrans = %d\n", retry,\
retrans);
}