Ken Arnold's version from UNIX Review
[unix-history] / usr / src / lib / libc / gen / gethostname.3
... / ...
CommitLineData
1.\" Copyright (c) 1983 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
5.\" @(#)gethostname.3 6.4 (Berkeley) %G%
6.\"
7.TH GETHOSTNAME 2 ""
8.UC 5
9.SH NAME
10gethostname, sethostname \- get/set name of current host
11.SH SYNOPSIS
12.nf
13.ft B
14gethostname(name, namelen)
15char *name;
16int namelen;
17.PP
18.ft B
19sethostname(name, namelen)
20char *name;
21int namelen;
22.fi
23.SH DESCRIPTION
24.I Gethostname
25returns the standard host name for the current processor, as
26previously set by
27.IR sethostname .
28The parameter
29.I namelen
30specifies the size of the
31.I name
32array. The returned name is null-terminated unless insufficient
33space is provided.
34.PP
35.I Sethostname
36sets the name of the host machine to be
37.IR name ,
38which has length
39.IR namelen .
40This call is restricted to the super-user and
41is normally used only when the system is bootstrapped.
42.SH "RETURN VALUE
43If the call succeeds a value of 0 is returned. If the call
44fails, then a value of \-1 is returned and an error code is
45placed in the global location \fIerrno\fP.
46.SH "ERRORS
47The following errors may be returned by these calls:
48.TP 15
49[EFAULT]
50The \fIname\fP or \fInamelen\fP parameter gave an
51invalid address.
52.TP 15
53[EPERM]
54The caller tried to set the hostname and was not the super-user.
55.SH SEE ALSO
56gethostid(2)
57.SH BUGS
58Host names are limited to MAXHOSTNAMELEN (from
59.IR <sys/param.h> )
60characters, currently 64.