gethostid() — Get the unique identifier of the current host
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4.2 |
both |
Format
X/Open:
#define _XOPEN_SOURCE_EXTENDED 1
#include <unistd.h>
long gethostid(void);
Berkeley sockets:
#define _OE_SOCKETS
#include <unistd.h>
int gethostid();
General description
The gethostid() call gets the unique 32-bit identifier for the current host. This value is the default home Internet address.
Special behavior for C++: To use this function with C++, you must use the _XOPEN_SOURCE_EXTENDED 1 feature test macro.
Returned value
If successful, gethostid() returns the 32-bit identifier of the current host, which should be unique across all hosts.
If unsuccessful, gethostid() returns -1 and stores the error value in errno. For return codes, see z/OS UNIX System Services Messages and Codes.