sethostname Subroutine

Purpose

Sets the name of the current host.

Library

Standard C Library (libc.a)

Syntax

int sethostname ( Name,  NameLength)
char *Name;
int NameLength;

Description

The sethostname subroutine sets the name of a host machine. Only programs with a root user ID can use this subroutine.

The sethostname subroutine allows a calling process with root user authority to set the internal host name of a machine on a network.

All applications containing the sethostname subroutine must be compiled with the _BSD macro set to a specific value. Acceptable values are 43 and 44. In addition, all socket applications must include the BSD libbsd.a library.

Parameters

Item Description
Name Specifies the name of the host machine.
NameLength Specifies the length of the Name array.

Return Values

Upon successful completion, the system returns a value of 0.

If the sethostname subroutine is unsuccessful, the subroutine handler performs the following functions:

Error Codes

The sethostname subroutine is unsuccessful if any of the following errors occurs:

Error Description
EFAULT The Name parameter or NameLength parameter gives an address that is not valid.
EPERM The calling process did not have an effective root user ID.