The gethostbyname callable service returns the alias names and the internet addresses of a host whose domain name is specified as input. The TCP/IP Services resolver tries to resolve the name through a name server, if one is present. If a name server is not present, the resolver searches for the HOSTS.SITEINFO data set (or /etc hosts data set) until a matching host name is found, or until an EOF marker is reached.
Operation | Environment |
---|---|
Authorization: | Supervisor state or problem state, any PSW key |
Dispatchable unit mode: | Task |
Cross memory mode: | PASN = HASN |
AMODE (BPX1GHN): | 31-bit |
AMODE (BPX4GHN): | 64-bit |
ASC mode: | Primary mode |
Interrupt status: | Enabled for interrupts |
Locks: | Unlocked |
Control parameters: | All parameters must be addressable by the caller and in the primary address space. |
|
AMODE 64 callers use BPX4GHN with the same parameters. Hostent_ptr is a doubleword pointer field.
A string, up to 255 characters long, set to the host name that is being queried.
The name of a fullword that contains the length of the Name parameter.
Return_code | Explanation |
---|---|
HOST_NOT_FOUND | The host name specified by the Name parameter was not found. |
TRY_AGAIN | The host name specified by the Name parameter could not be resolved within the configured time interval. The request can be retried later. |
NO_RECOVERY | An unrecoverable error occurred. |
NO_DATA | The requested Name parameter is valid, but it does not have a record at the name server. |
The name of a fullword in which the gethostbyname service stores the reason code. The gethostbyname service returns Reason_code only if Return_value is -1. Reason_code further qualifies the Return_code value.
Reason codes lower than decimal 4096 are z/OS UNIX System Services return codes, and are documented in z/OS UNIX System Services Messages and Codes. Reason codes greater than decimal 4096 are returned by the resolver, and are described in z/OS V2R1.0 Communications Server: IP and SNA Codes.
An assembler macro (EZBREHST) that contains the hostent structure, gethostbyxxxx return codes, and reason codes is shipped in the installation's MACLIB SMP/E DDEF location.
The gethostbyname service does not support a fully reentrant environment. The Hostent structure that is returned is allocated at a task level, and is reused on subsequent gethostbyname calls. Therefore, at any time only one call can be occurring within a task. For example, if the mainline task has issued a gethostbyname call that has not completed, a signal handler that interrupts that thread's processing should not invoke the gethostbyname service.
The Hostent structure is freed when the task is terminated.
For an example using this callable service, see BPX1GHN (gethostbyname) example.