gethostname, sethostname --
get or set name of current host
int gethostname(char *name, size_t namelen);
int sethostname(char *name, size_t namelen);
The gethostname function returns the standard host name
for the current machine.
The namelen argument specifies the size of the array pointed
to by the name argument.
The returned name is null-terminated.
If namelen is an insufficient length to hold the host name,
then the returned name is truncated to (namelen - 1)
characters and null-terminated.
Host names are limited to 255 bytes.
sethostname sets the name of the host machine to be
name, which has length namelen.
This call is restricted to a privileged user and is normally used
only when the system is bootstrapped.
On successful completion, 0 is returned.
Otherwise, -1 is returned.
The following errors may be returned by these calls:
The name or namelen parameter gave an invalid address.
The caller does not have appropriate privilege to use
The gethostname routine conforms to X/Open
System Interfaces and Headers, Issue 4, Version 2.
The sethostname routine does not conform to any current
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004