1GETHOSTNAME(2) System Calls Manual GETHOSTNAME(2)
2
3
4
6 gethostname, sethostname - get/set name of current host
7
9 gethostname(name, namelen)
10 char *name;
11 int namelen;
12
13 sethostname(name, namelen)
14 char *name;
15 int namelen;
16
18 Gethostname returns the standard host name for the current processor,
19 as previously set by sethostname. The parameter namelen specifies the
20 size of the name array. The returned name is null-terminated unless
21 insufficient space is provided.
22
23 Sethostname sets the name of the host machine to be name, which has
24 length namelen. This call is restricted to the super-user and is nor‐
25 mally used only when the system is bootstrapped.
26
28 If the call succeeds a value of 0 is returned. If the call fails, then
29 a value of -1 is returned and an error code is placed in the global
30 location errno.
31
33 The following errors may be returned by these calls:
34
35 [EFAULT] The name or namelen parameter gave an invalid address.
36
37 [EPERM] The caller tried to set the hostname and was not the
38 super-user.
39
41 gethostid(2)
42
44 Host names are limited to MAXHOSTNAMELEN (from <sys/param.h>) charac‐
45 ters, currently 64.
46
47
48
494.2 Berkeley Distribution May 22, 1986 GETHOSTNAME(2)