Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ gethostname(2) — Ultrix-11 3.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

hostname(1)

uname(2)

gethostname(2)

NAME

gethostname, sethostname − get/set name of current host

SYNTAX

int gethostname(name, namelen)
char *name;
int namelen;

int sethostname(name, namelen)
char *name;
int namelen;

DESCRIPTION

The gethostname system call returns the standard host name for the current processor that was previously set by the sethostname call.  The specified namelen specifies the size of the name array.  The returned name is null-terminated, unless insufficient space is provided. 

The sethostname system call sets the name of the host machine to be name, which has length namelen. 

RESTRICTIONS

The sethostname call is restricted to the superuser and is normally used only when the system is bootstrapped. 

Host names are limited to 16 characters. 

The gethostname and sethostname system calls are actually called as ghostname and shostname.  Due to the current constraint that function names must be significant in the first seven characters, the real names were shortened to keep them from clashing with the gethostid and sethostid calls.  However, you can use gethostname and sethostname without needing to worry about their real names, because the C preprocessor (/lib/cpp) re-defines them for you. 

RETURN VALUE

If unsuccessful, returns a −1, and the global variable errno indicates the error code. 

DIAGNOSTICS

The gethostname and sethostname calls will fail if:

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

[EPERM] The caller was not the superuser. 

SEE ALSO

hostname(1), uname(2)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026