The gethostname() call gets the standard host name for the local host machine.
Syntax
#include <unistd.h> int gethostname(name, namelen) char *name; int namelen;
Parameters
name
Description
This call copies the standard host name for the local host into the buffer specified by the name parameter. The returned name is a null-terminated string. If insufficient space is provided, the returned name is truncated to fit the given space. System host names are limited to 256 characters.
The gethostname() call allows a calling process to determine the internal host name for a machine on a network.
Return Values
The value 0 indicates success; the value -1 indicates an error.
Related Calls