The gethostname() function call is processed by a TCP/IP
stack. In a single-stack (INET) environment, the host name of the
active stack is returned. In a multi-stack (CINET) environment, the
gethostname() call is sent either to the stack with which the z/OS® UNIX user
has set affinity (for example, by setting the _BPXK_SETIBMOPT_TRANSPORT
environment variable) or, if there is no stack affinity, it is sent
to the default stack. The default stack in a CINET environment is
determined by SUBFILESYSTYPE statements in the BPXPRMxx parmlib member.
If the default stack is not active, the first stack that is activated
is designated as the default stack. You can display the current default
stack using the DISPLAY OMVS,PFS operator command. The FLAGS column
on the command output indicates which stack is the default. See z/OS MVS System Commands for the DISPLAY command output. See z/OS UNIX System Services Planning for information about how z/OS selects the default stack and how stack
affinity can be established.
The TCP/IP stack that receives the gethostname() function
call returns the host name value that was determined during stack
initialization. During initialization, the configuration component
of the stack issues the __iphost() function call to get the TCPIP.DATA
HOSTNAME statement value of the stack.
Note: If the HOSTNAME statement
is changed, TCPIP needs to be restarted for this change to take effect.
The z/OS UNIX search order for the started
task of the stack is used to find the TCPIP.DATA statement information
of the stack. The host name is determined in the following order:
- If the found TCPIP.DATA information contains a valid HOSTNAME
statement, its value is returned. If a system name parameter was specified
on the HOSTNAME statement, the parameter value is compared to one
of the following to determine whether the value matches the current
system name:
- If you have configured VMCF and TNF as non-restartable subsystems,
the system name is specified in the IEFSSNxx member
of PARMLIB.
- If you have configured VMCF and TNF as restartable subsystems,
the system name is obtained from the value of the P= parameter of
the EZAZSSI started procedure.
- If there is no valid HOSTNAME statement, the VMCF node name with
which VMCF was started is returned.
- If VMCF was not active when the stack was started, the CVTSNAME
value (this is the SYSNAME=value in the IEASYSxx member
that was used during the IPL) is returned.
If the host name came from TCPIP.DATA, the case used is the case
that was specified on the HOSTNAME statement. For VMCF or CVTSNAME,
the name is in uppercase.
The z/OS UNIX hostname command
must be issued from within the z/OS UNIX shell.