GETHOSTNAME(2) UNIX Programmer's Manual 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 _G_e_t_h_o_s_t_n_a_m_e returns the standard host name for the current processor, as previously set by _s_e_t_h_o_s_t_n_a_m_e. The parameter _n_a_m_e_l_e_n specifies the size of the _n_a_m_e array. The returned name is null-terminated unless insufficient space is pro- vided. _S_e_t_h_o_s_t_n_a_m_e sets the name of the host machine to be _n_a_m_e, which has length _n_a_m_e_l_e_n. This call is restricted to the super-user and is normally used only when the system is bootstrapped. RETURN VALUE If the call succeeds a value of 0 is returned. If the call fails, then a value of -1 is returned and an error code is placed in the global location _e_r_r_n_o. ERRORS The following errors may be returned by these calls: [EFAULT] The _n_a_m_e or _n_a_m_e_l_e_n parameter gave an invalid address. [EPERM] The caller tried to set the hostname and was not the super-user. SEE ALSO gethostid(2) BUGS Host names are limited to MAXHOSTNAMELEN (from <_s_y_s/_p_a_r_a_m._h>) characters, currently 64. Printed 11/26/99 May 22, 1986 1