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

Technical Reference: Communications, Volume 2


gethostent Subroutine

Purpose

Retrieves a network host entry.

Library

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

Syntax

#include <netdb.h>
 
struct hostent *gethostent ()

Description

When using DNS/BIND name service resolution, gethostent is not defined.

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

The gethostent subroutine returns a pointer to a hostent structure, which contains the equivalent fields for a host description line in the /etc/hosts file. The hostent structure is defined in the netdb.h file.

Return Values

Upon successful completion, the gethostent subroutine returns a pointer to a hostent structure.

Note: The return value points to static data that is overwritten by subsequent calls, so it must be copied to be saved.

If an error occurs or the end of the file is reached, the gethostent subroutine returns a null pointer.

Implementation Specifics

The gethostent subroutine is part of Base Operating System (BOS) Runtime.

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

The gethostbyaddr subroutine, gethostbyname subroutine, sethostent subroutine endhostent subroutine.

Sockets Overview and Network Address Translation in AIX 5L Version 5.1 Communications Programming Concepts.


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