Table of Contents

NAME

gethostname, sethostname - get/set host name

SYNOPSIS

#include <unistd.h>

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

DESCRIPTION

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

RETURN VALUE

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

ERRORS

EINVAL
For gethostname, name points to NULL or name is longer than len.
EPERM
For sethostname, the caller was not the superuser.
EINVAL
For sethostname, len was too long.

CONFORMING TO

POSIX.1 does not define these functions, but ISO/IEC 9945-1:1990 mentions them in B.4.4.1.

BUGS

gethostname is not compliant with other implementations, since they always return len bytes, even if name is longer. Linux, however, returns EINVAL in this case (as of DLL 4.4.1 libraries).

NOTES

Under Linux, gethostname is implemented at the library level by calling uname(2).

SEE ALSO

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


Table of Contents


www.fiveanddime.net


Google
Web www.fiveanddime.net