GETHOSTNAME(2,L) AIX Technical Reference GETHOSTNAME(2,L)
-------------------------------------------------------------------------------
gethostname, sethostname
PURPOSE
Gets or sets the name of the current host.
SYNTAX
int gethostname (name, namelen) int sethostname (name, namelen)
char *name; char *name;
int namelen; int namelen;
DESCRIPTION
The gethostname system call returns the standard host name of the current host,
as set by sethostname. The parameter namelen specifies the size of the name
array. The returned name is null-terminated unless insufficient space is
provided.
The sethostname system call sets the name of the host machine name with the
length namelen. This system call can only be used by processes with an
effective user ID of superuser. In the AIX Operating System, the host name of
a machine is usually set by AIX TCP/IP in its initialization program
(/etc/rc.tcpip).
RETURN VALUE
Upon successful completion, a value of 0 is returned. If the gethostname or
sethostname system call fails, a value of -1 is returned, and errno is set to
indicate the error.
ERROR CONDITIONS
The system call fails if one or more of the following are true:
EFAULT The name parameter or namelen parameter gives an address that is not
valid.
EPERM The calling process did not have an effective user ID of superuser.
RELATED INFORMATION
In this book: "gethostid, sethostid."
The hostname command in AIX TCP/IP User's Guide.
Processed November 7, 1990 GETHOSTNAME(2,L) 1