sethostent_r Subroutine

Purpose

Opens network host file.

Library

Standard C Library (libc.a)
(libbind)
libnis)
(liblocal)

Syntax

#include <netdb.h>
sethostent_r (StayOpenflag, ht_data)

int StayOpenflag;
struct hostent_data *ht_data;

Description

When using the sethostent_r subroutine in DNS/BIND name service resolution, sethostent_r allows a request for the use of a connected socket using TCP for queries. If the StayOpen parameter is non-zero, this sets the option to send all queries to the name server using TCP and to retain the connection after each call to gethostbyname_r or gethostbyaddr_r.

When using the sethostent_r subroutine to search the /etc/hosts file, sethostent_r opens and rewinds the /etc/hosts file. If the StayOpen parameter is non-zero, the hosts database is not closed after each call to gethostbyname_r or gethostbyaddr_r. It internally runs the sethostent command.

Parameters

Item Description
StayOpenflag When used in NIS name resolution and to search the local /etc/hosts file, it contains a value used to indicate whether to close the host file after each call to the gethostbyname and gethostbyaddr subroutines. A non-zero value indicates not to close the host file after each call, and a zero value allows the file to be closed.

When used in DNS/BIND name resolution, a non-zero value retains the TCP connection after each call to gethostbyname and gethostbyaddr. A value of zero allows the connection to be closed.

ht_data Points to the hostent_data structure.

Files

Item Description
/etc/hosts Contains the host name database.
/etc/netsvc.conf Contains the name services ordering.
/etc/include/netdb.h Contains the network database structure.