version 1, including all changes.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
GETHOSTNAME |
|
|
2 |
!!!GETHOSTNAME |
|
|
3 |
NAME |
|
|
4 |
SYNOPSIS |
|
|
5 |
DESCRIPTION |
|
|
6 |
RETURN VALUE |
|
|
7 |
ERRORS |
|
|
8 |
CONFORMING TO |
|
|
9 |
BUGS |
|
|
10 |
NOTES |
|
|
11 |
SEE ALSO |
|
|
12 |
---- |
|
|
13 |
!!NAME |
|
|
14 |
|
|
|
15 |
|
|
|
16 |
gethostname, sethostname - get/set host name |
|
|
17 |
!!SYNOPSIS |
|
|
18 |
|
|
|
19 |
|
|
|
20 |
__#include __ |
|
|
21 |
|
|
|
22 |
|
|
|
23 |
__int gethostname(char *__''name''__, size_t__ |
|
|
24 |
''len''__); |
|
|
25 |
int sethostname(const char *__''name''__, size_t__ |
|
|
26 |
''len''__);__ |
|
|
27 |
!!DESCRIPTION |
|
|
28 |
|
|
|
29 |
|
|
|
30 |
These functions are used to access or to change the host |
|
|
31 |
name of the current processor. |
|
|
32 |
!!RETURN VALUE |
|
|
33 |
|
|
|
34 |
|
|
|
35 |
On success, zero is returned. On error, -1 is returned, and |
|
|
36 |
''errno'' is set appropriately. |
|
|
37 |
!!ERRORS |
|
|
38 |
|
|
|
39 |
|
|
|
40 |
__EINVAL__ |
|
|
41 |
|
|
|
42 |
|
|
|
43 |
''len'' is negative or, for __sethostname__, |
|
|
44 |
''len'' is larger than the maximum allowed size, or, for |
|
|
45 |
__gethostname__ on Linux/i386, ''len'' is smaller than |
|
|
46 |
the actual size. (In this last case glibc 2.1 uses |
|
|
47 |
ENAMETOOLONG.) |
|
|
48 |
|
|
|
49 |
|
|
|
50 |
__EPERM__ |
|
|
51 |
|
|
|
52 |
|
|
|
53 |
For __sethostname__, the caller was not the |
|
|
54 |
superuser. |
|
|
55 |
|
|
|
56 |
|
|
|
57 |
__EFAULT__ |
|
|
58 |
|
|
|
59 |
|
|
|
60 |
''name'' is an invalid address. |
|
|
61 |
!!CONFORMING TO |
|
|
62 |
|
|
|
63 |
|
|
|
64 |
SVr4, 4.4BSD (this function first appeared in 4.2BSD). |
|
|
65 |
POSIX.1 does not define these functions, but ISO/IEC |
|
|
66 |
9945-1:1990 mentions them in B.4.4.1. |
|
|
67 |
!!BUGS |
|
|
68 |
|
|
|
69 |
|
|
|
70 |
According to the SUSv2, __gethostname__ must return |
|
|
71 |
''len'' bytes (a truncated hostname, NUL-terminated or |
|
|
72 |
not) when the hostname is longer. Linux/Alpha (which has a |
|
|
73 |
system call __gethostname__) complies with this |
|
|
74 |
requirement, but libc and glibc on Linux/i386 only return an |
|
|
75 |
error in this case. |
|
|
76 |
!!NOTES |
|
|
77 |
|
|
|
78 |
|
|
|
79 |
The definition of success varies. SUSv2 defines |
|
|
80 |
''gethostname()'' as `return possibly truncated |
|
|
81 |
hostname', and having a small ''len'' does not cause an |
|
|
82 |
error return. Of course it must be possible to be certain |
|
|
83 |
that one has obtained the full hostname, and to this end |
|
|
84 |
SUSv2 guarantees that `Host names are limited to 255 |
|
|
85 |
bytes'. |
|
|
86 |
!!SEE ALSO |
|
|
87 |
|
|
|
88 |
|
|
|
89 |
getdomainname(2), setdomainname(2), |
|
|
90 |
uname(2) |
|
|
91 |
---- |