gethostname()

NAME

gethostname() - get name of current host

SYNOPSIS

#include <unistd.h>

int gethostname (char *name, int namelen)

DESCRIPTION

The gethostname(2) function returns the standard host name for the current processor. The parameter namelen specifies the size of the name array. The returned name is null-terminated unless insufficient space is provided.

RETURN VALUES

If the call succeeds, it returns 0. If the call fails, it returns -1 and sets errno to indicate the error.

ERRORS

The following errors may be returned by these calls:

[EFAULT]
The name or namelen parameter gave an invalid address.

BUGS

Host names are limited to {MAXHOSTNAMELEN} (from <limits.h>) characters.