sethostent()--Open Host Database
Syntax
#include <netdb.h>
void sethostent(int stay_open)
Service Program Name: QSOSRV2
Default Public Authority: *USE
Threadsafe: No; see
Usage Notes.
The sethostent() function is used to prepare for sequential access
to the host database file. sethostent() opens the file and repositions
the file marker to the beginning of the file. In addition,
sethostent() affects what type of transport service (connectionless
versus connection-oriented) is to be used when gethostbyname() and
gethostbyaddr() need to retrieve host information from the domain name
server.
Parameters
- int stay_open
- (Input) Specifies whether to leave the database file open after each call
to gethostbyname() and gethostbyaddr(). A nonzero value
results in the database file being left open. Also, a nonzero value results in
the use of a connection-oriented transport service (for example, TCP) being
used by gethostbyname() and gethostbyaddr() when host
information is to be obtained from the domain name server.
Authorities
No authorization is required.
Error Conditions
When sethostent() fails, h_errno (defined in
<netdb.h>) can be set to one of the following:
- NO_RECOVERY
An unrecoverable error has occurred.
- The iSeries Navigator or the following CL commands can be
used to access the host database file:
- ADDTCPHTE (Add TCP/IP Host Table Entry
- RMVTCPHTE (Remove TCP/IP Host Table Entry)
- CHGTCPHTE (Change TCP/IP Host Table Entry)
- RNMTCPHTE (Rename TCP/IP Host Table Entry)
- MRGTCPHT (Merge TCP/IP Host Tables)
- Do not use the sethostent() function in a multithreaded
environment. See the multithread alternative sethostent_r()
function.
- When you develop in C-based languages and an application is compiled with
the _XOPEN_SOURCE macro defined to the value 520 or greater, the sethostent()
API is mapped toqso_sethostent98().
Related Information
API introduced: V3R1