Go to the previous, next section.

gethostname and sethostname

SYNOPSIS

int gethostname(char *name, size_t len);

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

PARAMETERS

name: (For gethostname) [out] points to a buffer where to put the host name. (For sethostname) [in] points to the new host name.

len: [in] the maximum length of name.

DESCRIPTION

gethostname returns the host name of the current host and sethostname sets it. Only the superuser may call sethostname.

RETURN VALUE

On success zero is returned. On error, -1 is returned and errno is set to one of the following values:

In the case of gethostname: EINVAL: name is NULL or the host name is longer than len.

In the case of sethostname:

Go to the previous, next section.