man pages section 3: Networking Library Functions

Exit Print View

Updated: July 2014
 
 

gethostname(3XNET)

Name

gethostname - get name of current host

Synopsis

cc [ flag ... ] file ... –lxnet [ library ... ]
#include <unistd.h> 

int gethostname(char *name, size_t namelen);

Description

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, except that if namelen is an insufficient length to hold the host name, then the returned name is truncated and it is unspecified whether the returned name is null-terminated.

Host names are limited to 255 bytes.

Return Values

On successful completion, 0 is returned. Otherwise, –1 is returned.

Errors

No errors are defined.

Attributes

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Interface Stability
Committed
MT-Level
MT-Safe
Standard

See also

uname(1), gethostid(3C), attributes(5), standards(5)