ualarm
[unix-history] / usr / src / lib / libc / gen / gethostname.3
CommitLineData
6712d93b
KM
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.\"
fd690c8b 5.\" @(#)gethostname.3 6.2 (Berkeley) %G%
6712d93b 6.\"
4d772387 7.TH GETHOSTNAME 2 ""
6712d93b
KM
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 int 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]
fd690c8b 54The caller tried to set the hostname and was not the super-user.
6712d93b
KM
55.SH SEE ALSO
56gethostid(2)
57.SH BUGS
4d772387
KM
58Host names are limited to
59.I 32
60characters.