Use the GETHOSTID command to return the primary IPv4 address for the current host. The primary address is the IP address of the default home address that is specified in the TCP/IP configuration file for the stack with which the current socket set is associated.
This command has no parameters.
This command returns a string that contains the return code and the primary IPv4 address of the host, for example, "0 10.11.103.1". The return code can be 0 or the REXX API error number. The return code 0 indicates that the requested socket command was completed successfully.
See Socket call error return codes for additional information about the numeric error codes that are returned by this command.
int gethostid();
/* REXX EZARXR10 */
/*
* This sample demonstrates the use of the GETHOSTID
* socket command.
*/
src = socket("INITIALIZE","MYSET01");
if perror(src,"INITIALIZE") = 0 then do
say socket("GETHOSTID");
end;
src = socket("TERMINATE","MYSET01");
src = perror(src,"TERMINATE");
exit 0;
/* This routine returns -1 if the first word if arg 1 is not zero */
perror: if word(arg(1),1) = 0 then return 0; else
Say arg(2) "Error : "arg(1);
return -1;