Copyright (C) 2000-2012 |
Manpages GETHOSTNAMESection: Linux Programmer's Manual (2)Updated: 1995-07-22 Index Return to Main Contents NAMEgethostname, sethostname - get/set host nameSYNOPSIS#include <unistd.h>
int gethostname(char *name, size_t len);
DESCRIPTIONThese functions are used to access or to change the host name of the current processor.RETURN VALUEOn success, zero is returned. On error, -1 is returned, and errno is set appropriately.ERRORS
CONFORMING TOSVr4, 4.4BSD (this function first appeared in 4.2BSD). POSIX.1 does not define these functions, but ISO/IEC 9945-1:1990 mentions them in B.4.4.1.BUGSAccording to the SUSv2, gethostname must return len bytes (a truncated hostname, NUL-terminated or not) when the hostname is longer. Linux/Alpha (which has a system call gethostname) complies with this requirement, but libc and glibc on Linux/i386 only return an error in this case.NOTESThe definition of success varies. SUSv2 defines gethostname() as `return possibly truncated hostname', and having a small len does not cause an error return. Of course it must be possible to be certain that one has obtained the full hostname, and to this end SUSv2 guarantees that `Host names are limited to 255 bytes'.SEE ALSOgetdomainname(2), setdomainname(2), uname(2)
IndexThis document was created by man2html, using the manual pages. Time: 09:27:57 GMT, April 20, 2024 |