1 <!-- Copyright (C) 2003 Red Hat, Inc. -->
2 <!-- This material may be distributed only subject to the terms -->
3 <!-- and conditions set forth in the Open Publication License, v1.0 -->
4 <!-- or later (the latest version is presently available at -->
5 <!-- http://www.opencontent.org/openpub/). -->
6 <!-- Distribution of the work or derivative of the work in any -->
7 <!-- standard (paper) book form is prohibited unless prior -->
8 <!-- permission is obtained from the copyright holder. -->
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
19 TITLE="eCos Reference Manual"
20 HREF="ecos-ref.html"><LINK
22 TITLE="TCP/IP Library Reference"
23 HREF="tcpip-library-reference.html"><LINK
25 TITLE="TCP/IP Library Reference"
26 HREF="tcpip-library-reference.html"><LINK
29 HREF="net-common-tcpip-manpages-byteorder.html"></HEAD
40 SUMMARY="Header navigation table"
49 >eCos Reference Manual</TH
57 HREF="tcpip-library-reference.html"
65 >Chapter 38. TCP/IP Library Reference</TD
71 HREF="net-common-tcpip-manpages-byteorder.html"
85 NAME="NET-COMMON-TCPIP-MANPAGES-GETHOSTNAME">gethostname</H1
94 >GETHOSTNAME(3) System Library Functions Manual GETHOSTNAME(3)
97 gethostname, sethostname - get/set name of current host
100 #include <unistd.h>
103 gethostname(char *name, size_t namelen);
106 sethostname(const char *name, size_t namelen);
109 The gethostname() function returns the standard host name for the current
110 processor, as previously set by sethostname(). The parameter namelen
111 specifies the size of the name array. If insufficient space is provided,
112 the returned name is truncated. The returned name is always null termi-
115 sethostname() sets the name of the host machine to be name, which has
116 length namelen. This call is restricted to the superuser and is normally
117 used only when the system is bootstrapped.
120 If the call succeeds a value of 0 is returned. If the call fails, a
121 value of -1 is returned and an error code is placed in the global vari-
125 The following errors may be returned by these calls:
127 [EFAULT] The name or namelen parameter gave an invalid address.
129 [EPERM] The caller tried to set the hostname and was not the
133 hostname(1), getdomainname(3), gethostid(3), sysctl(3), sysctl(8), yp(8)
136 The gethostname() function call conforms to X/Open Portability Guide
137 Issue 4.2 (``XPG4.2'').
140 The gethostname() function call appeared in 4.2BSD.
143 Host names are limited to MAXHOSTNAMELEN (from <sys/param.h>) characters,
144 currently 256. This includes the terminating NUL character.
146 If the buffer passed to gethostname() is smaller than MAXHOSTNAMELEN,
147 other operating systems may not guarantee termination with NUL.
160 SUMMARY="Footer navigation table"
171 HREF="tcpip-library-reference.html"
189 HREF="net-common-tcpip-manpages-byteorder.html"
199 >TCP/IP Library Reference</TD
205 HREF="tcpip-library-reference.html"