*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->Linux man pages -> gethostname (2)              
Title
Content
Arch
Section
 

GETHOSTNAME(2)

Contents


NAME    [Toc]    [Back]

       gethostname, sethostname - get/set host name

SYNOPSIS    [Toc]    [Back]

       #include <unistd.h>

       int gethostname(char *name, size_t len);
       int sethostname(const char *name, size_t len);

DESCRIPTION    [Toc]    [Back]

       These  functions  are  used to access or to change the host name of the
       current processor.

RETURN VALUE    [Toc]    [Back]

       On success, zero is returned.  On error, -1 is returned, and  errno  is
       set appropriately.

ERRORS    [Toc]    [Back]

       EINVAL len is negative or, for sethostname, len is larger than the maximum
 allowed size, or, for gethostname  on  Linux/i386,  len  is
	      smaller than the actual size.  (In this last case glibc 2.1 uses
	      ENAMETOOLONG.)

       EPERM  For sethostname, the caller was not the superuser.

       EFAULT name is an invalid address.

CONFORMING TO    [Toc]    [Back]

       SVr4, 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.

BUGS    [Toc]    [Back]

       According 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.

NOTES    [Toc]    [Back]

       The 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 ALSO    [Toc]    [Back]

      
      
       getdomainname(2), setdomainname(2), uname(2)



Linux 1.3.6			  1995-07-22			GETHOSTNAME(2)
[ Back ]
 Similar pages
Name OS Title
rcp Tru64 Copies files on the same host, between a local host and a remote host, and between two remote hosts
ssh-hostbased-setup Tru64 Sets up Secure Shell host-based authentication by verifying and if necessary, copying a public host ...
t6rhdb_put_host IRIX TSIX Remote Host DataBase get host information
t6rhdb_get_host IRIX TSIX Remote Host DataBase get host information
upl OpenBSD USB support for Prolific based host-to-host adapters
rsh Tru64 Executes a specified command on a remote host or logs into a remote host
sethostname HP-UX set name of host cpu
dced HP-UX DCE Host daemon
sethostname NetBSD get/set name of current host
sethostname OpenBSD get/set name of current host
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service