GETHOSTNAME(2) COMMAND REFERENCE GETHOSTNAME(2) NAME gethostname, sethostname - get/set name of current host SYNOPSIS gethostname(name, namelen) char *name; int namelen; sethostname(name, namelen) char *name; int namelen; DESCRIPTION The command gethostname returns the standard host name for the current processor, as previously 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 command sethostname sets the name of the host machine to name, which has length namelen; this call is restricted to the superuser and is normally used only when the system is bootstrapped. DIAGNOSTICS The following errors may be returned by these calls: [EFAULT] The name or namelen parameter gave an invalid address. [EPERM] The caller was not the superuser; applies only to sethostname. RETURN VALUE [0] Successful call. [-1] Unsuccessful call. An error code is placed in the global location errno. CAVEATS Host names are limited to 31 characters. SEE ALSO gethostid(2). Printed 5/12/88 1
%%index%% na:408,107; sy:515,1145; de:1660,988; di:2648,505; rv:3153,256; ca:3409,125; se:3534,126; %%index%%000000000123