Loading...
Select Version
&pagelevel(4)&pagelevel
|
Description
The gethostname() function returns the socket host name for the current host in the name parameter. The length of the name string variable must be specified in the namelen parameter when gethostname() is called.
If the length of the name string variable specified by namelen suffices for storing the host name, the host name is terminated with a null byte. Otherwise, the excess socket host name characters are truncated and it is then undefined whether the host name returned in this way is terminated by a null byte.
Return value
0:
If successful.
-1:
If errors occur. errno is set to indicate the error.