sethostent()--Open Local Host Table
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 local host table. sethostent() opens the table and repositions to the beginning of the table. 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 local host table open after each call to gethostbyname() and gethostbyaddr(). A nonzero value results in the local host table 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.
Usage Notes
- System i® Navigator or the following CL commands can be
used to access the local host table:
- 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)
- CFGTCP (Configure TCP/IP), option "10. Work with TCP/IP host table entries"
- 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
- _XOPEN_SOURCE--Using _XOPEN_SOURCE for the UNIX® 98
compatible interface
- gethostbyaddr()--Get Host Information for IP
Address
- gethostbyname()--Get Host Information for Host
Name
- endhostent()--Close Local Host Table
- gethostent()--Get Next Entry from Local Host Table
API introduced: V3R1