sethostent_r()--Open Host Database


  Syntax
 #include <netdb.h>

 int sethostent_r(int stay_open,
        struct hostent_data *hostent_data_struct_addr)

  Service Program Name: QSOSRV2

  Default Public Authority: *USE

  Threadsafe: Yes

The sethostent_r() function is used in preparation for sequential access to the host database file. The sethostent_r() function opens the file and repositions the file marker to the beginning of the file. In addition, this call affects what type of transport service (connectionless versus connection-oriented) that is to be used when gethostbyname_r() and gethostbyaddr_r() 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_r() and gethostbyaddr_r(). A non-zero value will result in the database file being left open. Also, a non-zero value will result in the use of a connection-oriented transport service (for example, TCP) being used by gethostbyname_r() and gethostbyaddr_r() when host information is to be obtained from the domain name server.

struct hostent_data *hostent_data_struct_addr  (input/output) 
Specifies the pointer to the hostent_data structure, which is used to pass and preserve results between function calls. The field host_control_blk in the hostent_data structure must be initialized with hexadecimal zeros before its initial use. If compatibility with other platforms is required, then the entire hostent_data structure must be initialized to hexadecimal zeros before initial use.

Authorities

No authorization is required.


Return Value

The sethostent_r() function returns an integer. Possible values are:

The struct hostent_datadenoted by hostent_data_struct_addr is defined in <netdb.h>.


Error Conditions

When the sethostent_r() function fails, h_errno (defined in <netdb.h>) can be set to:

[NO_RECOVERY]

An unrecoverable error has occurred.

When the sethostent_r() function fails, errno can be set to:

[EINVAL]

The hostent_data structure was not properly initialized to hexadecimal zeros before initial use. For corrective action, see the description for structure hostent_data.


Usage Notes

The iSeries Navigator or the following CL commands can be used to access the host database file:


Related Information



API introduced: V4R2
Top | UNIX-Type APIs | APIs by category