GETHOSTNAME(2) System Calls Manual GETHOSTNAME(2)
gethostname, sethostname - get/set name of current host
int gethostname(name, namelen)
int sethostname(name, namelen)
gethostname() returns the standard host name for the current processor,
as previously set by sethostname(). The parameter namelen specifies
the size of the array pointed to by name. The returned name is null-
terminated unless insufficient space is provided.
sethostname() sets the name of the host machine to be name, which has
length namelen. This call is restricted to the super-user and is nor-
mally used only when the system is bootstrapped.
gethostname() and sethostname() return:
0 on success.
-1 on failure and set errno to indicate the error.
EFAULT The name or namelen parameter gave an invalid address.
In addition to the above, sethostname() may set errno to:
EPERM The caller was not the super-user.
Host names are limited to MAXHOSTNAMELEN (from <<sys/param.h>>) charac-
ters, currently 64.
21 January 1990 GETHOSTNAME(2)