[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Communications, Volume 2

gethostent_r Subroutine

Purpose

Retrieves a network host entry.

Library

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

Syntax

#include <netdb.h>
 
int gethostent_r (htent, ht_data)
struct hostent *htent;
struct hostent_data *ht_data;

Description

When using DNS/BIND name service resolution, the gethostent_r subroutine is not defined.

When using NIS name service resolution or searching the local /etc/hosts file, the gethostent_r subroutine reads the next line of the /etc/hosts file, and opens the file if necessary.

The gethostent_r subroutine internally calls the gethostent subroutine, and stores the values in the htent and ht_data structures.

The gethostent subroutine overwrites the static data returned in subsequent calls. The gethostent_r subroutine does not.

Parameters

htent Points to the hostent structure
ht_data Points to the hostent_data structure

Return Values

This subroutine returns a 0 if successful, and a -1 if unsuccessful.

Files

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

Related Information

gethostbyaddr_r Subroutine, gethostbyname_r Subroutine, sethostent_r Subroutine, and endhostent_r Subroutine.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]